Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

Word FAQ problem (Bill Coan author)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg Maxey - 18 Oct 2006 14:52 GMT
Bill,

I tried to run your code found here:

http://word.mvps.org/FAQs/InterDev/ControlXLFromWord.htm

Regardless if Excel is running or not, I alway get an error message
50290.
Jean-Guy Marcil - 18 Oct 2006 15:48 GMT
Greg Maxey was telling us:
Greg Maxey nous racontait que :

> Bill,
>
[quoted text clipped - 4 lines]
> Regardless if Excel is running or not, I alway get an error message
> 50290.

Which line of code errors out?

Can you post the relevant code?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Greg Maxey - 18 Oct 2006 16:35 GMT
JGM,

Sorry.

Excel is "not" open when I run the code.

The error occurs on the line:
Set oWB = oXL.Workbooks.Open(FileName:=WorkbookToWorkOn)

I know now why the error is thrown.

For some reason the following code is not throwing an error as the code
indicates it should if Excel is "not" already opened:

'If Excel is running, get a handle on it; otherwise start a new
instance of Excel
On Error Resume Next
Set oXL = GetObject(, "Excel.Application")
If Err Then
  ExcelWasNotRunning = True
  Set oXL = New Excel.Application
End If

> Greg Maxey was telling us:
> Greg Maxey nous racontait que :
[quoted text clipped - 18 lines]
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
Jean-Guy Marcil - 18 Oct 2006 16:49 GMT
Greg Maxey was telling us:
Greg Maxey nous racontait que :

> JGM,
>
[quoted text clipped - 4 lines]
> The error occurs on the line:
> Set oWB = oXL.Workbooks.Open(FileName:=WorkbookToWorkOn)

Have you tried adding the line
   oXL.Visible = True
just before the "Set oWB..." line just to make sure that the application was
indeed created properly?

> I know now why the error is thrown.
>
> For some reason the following code is not throwing an error as the
> code indicates it should if Excel is "not" already opened:

You mean that "If Err" is False when there are no Excel application running?
Are you sure you do not have an invisible application running (Sometimes an
Office application is not present in the Applications tab of the Windows
Task Manager, but is actually present in the Processes tab).

> 'If Excel is running, get a handle on it; otherwise start a new
> instance of Excel
[quoted text clipped - 4 lines]
>   Set oXL = New Excel.Application
> End If

I ran the code as is form the web site (Just changed the path/name of the
Excel file) and it ran without any problems, even when Excel was not
previously running.

Then, as a test. I used a wrong path, and the error was caught as it was
supposed to.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Greg Maxey - 18 Oct 2006 17:44 GMT
Hi JGM

"Are you sure you do not have an invisible application running
(Sometimes an
Office application is not present in the Applications tab of the
Windows Task Manager, but is actually present in the Processes tab)."

Knowledge is a wonderful thing isnt' it ;-)

> Greg Maxey was telling us:
> Greg Maxey nous racontait que :
[quoted text clipped - 19 lines]
>
> You mean that "If Err" is False when there are no Excel application running?

> > 'If Excel is running, get a handle on it; otherwise start a new
> > instance of Excel
[quoted text clipped - 18 lines]
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.