Home > Software engineering >  How to open the dialog opens an EXCEL and operate
How to open the dialog opens an EXCEL and operate

Time:09-20

For example I want to open a EXCEL, and from the above readings written in VB
 
Private Sub Command1_Click ()
Dim excel_App As Excel. Application
Dim excel_Book As Excel. The Workbook
Dim excel_sheet As Excel. The Worksheet
The Set excel_App=CreateObject (" Excel. Application ")
Excel_App. Visible=False
Set excel_Book=excel_App. Workbooks. Open (App) Path + "\ file A.x LSX")
The Set excel_sheet=excel_Book. Worksheets (" Sheet1 ")
Dim As Integer I
Dim j As Integer

Dim A (1 To 10, 1 To 12) As an Integer
For I=1 To 10
For j=1 To 12
A (I, j)=excel_sheet. Cells (I + 1, j + 1)
Print A (I, j);
If j=12 Then Print

Next j
Next I

End Sub

Don't do this way, but the pop-up a open operation box allows users to choose their own open the EXCEL file, how to write ah,



CodePudding user response:

http://bbs.csdn.net/topics/392162498

CodePudding user response:

reference 1st floor caozhy response:
http://bbs.csdn.net/topics/392162498


Is the same as the content of the questions, is the same as the code (" code style "is the same, just more over there a few words),
It must be the original poster another ma3 jia3,

CodePudding user response:

refer to the second floor Chen8013 response:
Quote: refer to 1st floor caozhy response:

http://bbs.csdn.net/topics/392162498


Is the same as the content of the questions, is the same as the code (" code style "is the same, just more over there a few words),
It must be the original poster another ma3 jia3,

Didn't look at, as if also is really of, saying CSDN ma3 jia3, under the simple calculate knew, CSDN tens of millions of all the registered users, this means that programmers all over China registered the CSDN account is not enough,

CodePudding user response:

Sub LoadExcelData ()
Dim WKBK As Workbook 'work to define a thin
Dim myFileName As String 'definition to read the file path
MyFileName=Application. GetOpenFilename (" EXCEL file (*. XLSX), *. XLS ") 'browse the file, such as XX to XX company 17 years table. XLS
If myFileName="False" Then "If cancel the pop-up dialog
MsgBox "please select a file!" , vbInformation, "cancel"
The Else
The Set WKBK=Workbooks. Open (myFileName) 'first Open to copy the file
WKBK. Activate 'Activate open workbook

.
Your code is
.


WKBK. Close False 'Close work thin

MsgBox "data import success!"
End the If
End Sub
  • Related