.


:




:

































 

 

 

 


Excel




 

Reference... Microsoft Excel Object Library.

 

Dim WS As Workspace

Dim DB As Database

Dim RS As Recordset

Dim strSQL As String

Dim strDBPath As String

Dim i As Integer

 

strDBPath = "C:\Program Files\Microsoft Visual _ Studio\VB98\Biblio.mdb"'

' :

Set WS = DBEngine.Workspaces(0)

' , strDBPath ( ' ), False , ' Exclusive (False), Read\Write

'(False)

Set DB = WS.OpenDatabase(strDBPath, False, False)

' Publishers, SQL

strSQL = "SELECT PubID, Name, Address, City, Telephone FROM Publishers"

Set RS = DB.OpenRecordset(strSQL)

' SQL

' Excel

i = 2

While RS.EOF = False

Sheets("sheet1").Range("a" + LTrim(Str(i))) = _ RS.Fields(0)

Sheets("sheet1").Range("b" + LTrim(Str(i))) = _ RS.Fields(1)

Sheets("sheet1").Range("c" + LTrim(Str(i))) = _ RS.Fields(2)

Sheets("sheet1").Range("d" + LTrim(Str(i))) = _ RS.Fields(3)

Sheets("sheet1").Range("e" + LTrim(Str(i))) = _ RS.Fields(4)

i = i + 1

RS.MoveNext

Wend

MsgBox ""

Excel

 

.

Reference... Microsoft Excel Object Library.

 

Set objExcel = New Excel.Application

objExcel.Visible = False

Set objWB = objExcel.Workbooks.Add

Set objSH = objExcel.Worksheets.Add

objExcel.ActiveWorkbook.SaveAs " "

objExcel.Quit

Set objExcel = Nothing

MsgBox " " & " " & " ", vbInformation, Tit

 

 

Visual Basic

 

, 2 Visual Basic, .

Reference... Microsoft Excel Object Library.

 

Dim Ex As New Excel.Application

 

Ex.Workbooks.Open < >

Ex.Visible = False

' "A2" "Visual Basic"

Ex.ActiveWorkbook.Sheets.Application.Range("A2") = "Visual_ Basic"

Ex.ActiveWorkbook.Save

Ex.ActiveWorkbook.Close

 

 

 

Reference... Microsoft Excel Object Library.

 

XL.Range("A1").Select ' 1

XL.ActiveSheet.Pictures.Insert("C:\Picture.jpg").Select _ '

 

 

,

 

Reference... Microsoft Excel Object Library.

 

Private Sub UserForm_Initialize()

TextBox1.Text = "Cut This text and Paste in Textbox2"

CommandButton1.Caption = "Cut and Paste"

CommandButton1.AutoSize = True

End Sub

 

Private Sub CommandButton1_Click()

TextBox1.SelStart = 0

TextBox1.SelLength = TextBox1.TextLength

TextBox1.Cut

'TextBox1.Copy

TextBox2.SetFocus

TextBox2.SelStart = 0

TextBox2.Paste

TextBox2.SelStart = 0

End Sub

 

 

 

Reference... Microsoft Excel Object Library.

 

Dim Ex As New Excel.Application

Ex.Workbooks.Open " "

Ex.Visible = False

Ex.ActiveWorkbook.Sheets.Application.Range("B1:B14").Select

Ex.ActiveWorkbook.Sheets.Application.Range("B14").Activate

Ex.ActiveWorkbook.Sheets.Application.ActiveCell.FormulaR1C1 = "=SUM(R[-13]C:R[-1]C)"

Ex.ActiveWorkbook.Sheets.Application.Range("B14").Select

Text1.Text = _ Ex.ActiveWorkbook.Sheets.Application.Range("B14")

Ex.ActiveWorkbook.Save

Ex.ActiveWorkbook.Close

 


[1]





:


: 2016-10-30; !; : 283 |


:

:

,
==> ...

2000 - | 1766 -


© 2015-2024 lektsii.org - -

: 0.01 .