Sorry, I'm beginner in VB6.
Now I want to open 2 kind of excel file.
First I define them A-File & B-File.
The A-file whose path is
Code:
Open(App.Path & "\" & "Convert Excel.xls")
But B-file which is variable file.
(I cant assure how many B-file)
I decide to use function in Module1 to control it.
Define global variable in module
Code:
Public op As Boolean
Public optime As Integer
Public singlefile(500) As String
This is openfile as B-File
Code:
Private Sub Open_Single_File_Click()
CommonDialog1.DialogTitle = "Open Single File"
CommonDialog1.Filter = "Machine File(*.txt)|*.txt|All File(*.*)|*.*"
CommonDialog1.Action = 1
Text2.Text = CommonDialog1.FileName
op = True
optime = optime + 1
singlefile(optime) = Text2.Text
Text1.Text = "Open Type -> Single = " & optime
End Sub
Creating open multiple excel file function
Code:
Public Function openexcel(ByVal optime_ As Integer, ByVal singlefile_ As String)
Dim xlapp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlapp = CreateObject("Excel.Application")
Set xlBook = xlapp.Workbooks.Open(singlefile_)
xlapp.DisplayAlerts = True
xlapp.Visible = False
End Function
Another Excel button
Code:
Private Sub Command2_Click()
cho = MsgBox("It must to have Excel,Do your computer have Excel?", vbOKCancel, "Caution")
If cho = vbOK Then
If op = True Then
Dim xlapp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlapp = CreateObject("Excel.Application")
Set xlBook = xlapp.Workbooks.Open(App.Path & "\" & "Convert Excel.xls")
xlapp.DisplayAlerts = True
xlapp.Visible = False
For l = 1 To optime '<--this have bug
Dim xlapp(l) As Excel.Application '<---This have but
xlapp(l) = openexcel(l, singlefile(l)) '<---this have but
Next l
Else
b = MsgBox("The file have not open yet!", vbOKOnly, "Caution")
End If
Else
End If
End Sub
Please help me to solution.