B
Brent McLaren
Hi,
I am trying to search for some text in the VBA code of Excel 97 files
from within VB6.0 using the code below. I copied most of the code
from an MSDN article but i keep getting an Automation Error (430). I
know other's have had the same problem in this group but i have not
been able to find a solution.
I have tried the code using VB6.0 and from within Excel 97 itself and
i get the same error. I have also tried referencing both "Microsoft
Visual Basic for Applications Extinsibility" and "Microsoft Visual
Basic for Applications Extinsibility 5.3". I am also referencing
"Microsoft Excel 8.0 Object Library".
If anyone has a solution to my problem your help would be greatly
appreciated.
Thanks,
Brent
Private Sub Command1_Click()
'Declare variables to access the Excel workbook
Dim objXLApp As Excel.Application
Dim objXLWorkbooks As Excel.Workbooks
Dim objXLABC As Excel.Workbook
'Declare variables to access the macros in the workbook
Dim objProject As VBIDE.VBProject
Dim objComponent As VBIDE.VBComponent
Dim objCode As VBIDE.CodeModule
'Declare other miscellaneous variables
Dim arrXLFileNames As Variant
Dim varFileName As Variant
Dim strFileName As String
'Empty the list box
List1.Clear
'Open Excel, and open the workbook
Set objXLApp = New Excel.Application
Set objXLWorkbooks = objXLApp.Workbooks
arrXLFileNames = Array("ImportReport97.xls", "DJEnergyIndex1.xls")
For Each varFileName In arrXLFileNames
strFileName = "\Brents Work\xlFiles\" & varFileName
Set objXLABC = objXLWorkbooks.Open(strFileName)
'Get the project details in the workbook
Set objProject = objXLABC.VBProject
'Iterate through each component in the project
'---------------------------------------------
'NEXT LINE CAUSES ERROR 430
'---------------------------------------------
For Each objComponent In objProject.VBComponents
'Find the code module for the project
Set objCode = objComponent.CodeModule
'Scan through the code module, connection string
If objCode.Find("Provider=""MSDORA""", 1, 1, -1, -1, True,
False, False) Then
List1.AddItem objXLABC.FullName
Exit For
End If
Next
Next
End Sub
I am trying to search for some text in the VBA code of Excel 97 files
from within VB6.0 using the code below. I copied most of the code
from an MSDN article but i keep getting an Automation Error (430). I
know other's have had the same problem in this group but i have not
been able to find a solution.
I have tried the code using VB6.0 and from within Excel 97 itself and
i get the same error. I have also tried referencing both "Microsoft
Visual Basic for Applications Extinsibility" and "Microsoft Visual
Basic for Applications Extinsibility 5.3". I am also referencing
"Microsoft Excel 8.0 Object Library".
If anyone has a solution to my problem your help would be greatly
appreciated.
Thanks,
Brent
Private Sub Command1_Click()
'Declare variables to access the Excel workbook
Dim objXLApp As Excel.Application
Dim objXLWorkbooks As Excel.Workbooks
Dim objXLABC As Excel.Workbook
'Declare variables to access the macros in the workbook
Dim objProject As VBIDE.VBProject
Dim objComponent As VBIDE.VBComponent
Dim objCode As VBIDE.CodeModule
'Declare other miscellaneous variables
Dim arrXLFileNames As Variant
Dim varFileName As Variant
Dim strFileName As String
'Empty the list box
List1.Clear
'Open Excel, and open the workbook
Set objXLApp = New Excel.Application
Set objXLWorkbooks = objXLApp.Workbooks
arrXLFileNames = Array("ImportReport97.xls", "DJEnergyIndex1.xls")
For Each varFileName In arrXLFileNames
strFileName = "\Brents Work\xlFiles\" & varFileName
Set objXLABC = objXLWorkbooks.Open(strFileName)
'Get the project details in the workbook
Set objProject = objXLABC.VBProject
'Iterate through each component in the project
'---------------------------------------------
'NEXT LINE CAUSES ERROR 430
'---------------------------------------------
For Each objComponent In objProject.VBComponents
'Find the code module for the project
Set objCode = objComponent.CodeModule
'Scan through the code module, connection string
If objCode.Find("Provider=""MSDORA""", 1, 1, -1, -1, True,
False, False) Then
List1.AddItem objXLABC.FullName
Exit For
End If
Next
Next
End Sub