A
avi
Hello,
I have found this code in a old posting that seems the right one to
get the a reference fron VB6 to the active Excel workbook. When
running it, i get "Sub or function not defined" that seems to refer to
CType . It could be that the code is written in VB.net. Could you help
with the right version for VB6 (if this is the problem)?
Sub Comm1()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim myBookName As String
xlApp = CType((GetObject(, "Excel.Application")),
Excel.Application)
xlBook = CType(xlApp.ActiveWorkbook, Excel.Workbook)
myBookName = xlBook.Name
MsgBox (myBookName)
End Sub
I have found this code in a old posting that seems the right one to
get the a reference fron VB6 to the active Excel workbook. When
running it, i get "Sub or function not defined" that seems to refer to
CType . It could be that the code is written in VB.net. Could you help
with the right version for VB6 (if this is the problem)?
Sub Comm1()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim myBookName As String
xlApp = CType((GetObject(, "Excel.Application")),
Excel.Application)
xlBook = CType(xlApp.ActiveWorkbook, Excel.Workbook)
myBookName = xlBook.Name
MsgBox (myBookName)
End Sub