John Sullivan
jonsulli at swbell.net
Thu Oct 9 15:05:26 CDT 2003
Jim, Given the path and name of an Excel sheet on my pc, this seems to work ok and gives the following in the debug window: 2 ThisWorkbook 2 Sheet1 2 If you have more than A97 installed on your test machine, check that the references are actually set and all match the version of office your running. HTH, John Sullivan Jim DeMarco wrote: >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". >*********************************************************************************** > >_______________________________________________ >AccessD mailing list >AccessD at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/accessd >Website: http://www.databaseadvisors.com > > >