[AccessD] Excel automation code fails

Jim DeMarco Jdemarco at hshhp.org
Thu Oct 9 14:32:22 CDT 2003


Can anyone tell me why this code returns an "Object does not support automation" error when run from a form code module, but works when pasted into the debug window?  App (A97) references the VBA Extensibility and Excel libraries.

<code>
Dim objXLapp As Excel.Application
Dim objXLWorkbooks As Excel.Workbooks
Dim objXLABC As Excel.Workbook

Dim objProject As VBIDE.VBProject
Dim objComponent As VBIDE.VBComponent


Set objXLapp = New Excel.Application
Set objXLWorkbooks = objXLapp.Workbooks
Set objXLABC = objXLWorkbooks.Open("c:\work\pcpfile.xls")
Set objProject = objXLABC.VBProject

Debug.Print objProject.VBComponents.Count 'code fails here from form module


For Each objComponent In objProject.VBComponents
   Debug.Print objComponent.Name
   Debug.Print objComponent.CodeModule.CountOfLines
Next
</code>

TIA,

Jim DeMarco
Director of Product Development
HealthSource/Hudson Health Plan


***********************************************************************************
"This electronic message is intended to be for the use only of the named recipient, and may contain information from Hudson Health Plan (HHP) that is confidential or privileged.  If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited.  If you have received this message in error or are not the named recipient, please notify us immediately, either by contacting the sender at the electronic mail address noted above or calling HHP at (914) 631-1611. If you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message.  Thank You".
***********************************************************************************



More information about the AccessD mailing list