PC Review


Reply
Thread Tools Rate Thread

Callling Word fronm Excel

 
 
Duane Reynolds 322310
Guest
Posts: n/a
 
      14th Feb 2008

I am stumped. I am running the below code to print a mail merge. Excel stars
> word , the mail merge macro in word runs and prints but Excel opens

debugger
and halts at .Documents.Open ("D:\Duane
Docs\Inspection_Report_browser_Merge2008_Fields.doc")
witrh the comment "Word can not open this file"
What am I missing here.
Thanks in advance
Duane

Sub ControlWordFromXL()


Dim objWord As Word.Application
'Set objWord = New Word.Application

With objWord
.Visible = True
.Activate
.WindowState = wdWindowStateMaximize
.Documents.Open ("D:\Duane
Docs\Inspection_Report_browser_Merge2008_Fields.doc")
End With
End Sub



 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      14th Feb 2008

It worked for me after removing the comment ( ' ) in front of Set.
(I used a correct file path/file for my system)
Also, it is a good idea to set object variables to nothing when using automation...
Add this line just before End Sub...
Set objWord = Nothing
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Duane Reynolds 322310"
wrote in message
I am stumped. I am running the below code to print a mail merge.
Excel stars > word , the mail merge macro in word runs and prints
but Excel opens debugger and halts at .Documents.Open ("D:\Duane
Docs\Inspection_Report_browser_Merge2008_Fields.doc")

witrh the comment "Word can not open this file"
What am I missing here.
Thanks in advance
Duane

Sub ControlWordFromXL()


Dim objWord As Word.Application
'Set objWord = New Word.Application

With objWord
.Visible = True
.Activate
.WindowState = wdWindowStateMaximize
.Documents.Open ("D:\Duane
Docs\Inspection_Report_browser_Merge2008_Fields.doc")
End With
End Sub



 
Reply With Quote
 
Duane Reynolds 322310
Guest
Posts: n/a
 
      14th Feb 2008
It runs and executes just fine on my system but opens debug and highlights
that one line leaves excel open
Duane
"Jim Cone" <(E-Mail Removed)> wrote in message
news:e9ASp%(E-Mail Removed)...
>
> It worked for me after removing the comment ( ' ) in front of Set.
> (I used a correct file path/file for my system)
> Also, it is a good idea to set object variables to nothing when using
> automation...
> Add this line just before End Sub...
> Set objWord = Nothing
> --
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
> (Excel Add-ins / Excel Programming)
>
>
>
> "Duane Reynolds 322310"
> wrote in message
> I am stumped. I am running the below code to print a mail merge.
> Excel stars > word , the mail merge macro in word runs and prints
> but Excel opens debugger and halts at .Documents.Open ("D:\Duane
> Docs\Inspection_Report_browser_Merge2008_Fields.doc")
>
> witrh the comment "Word can not open this file"
> What am I missing here.
> Thanks in advance
> Duane
>
> Sub ControlWordFromXL()
>
>
> Dim objWord As Word.Application
> 'Set objWord = New Word.Application
>
> With objWord
> .Visible = True
> .Activate
> .WindowState = wdWindowStateMaximize
> .Documents.Open ("D:\Duane
> Docs\Inspection_Report_browser_Merge2008_Fields.doc")
> End With
> End Sub
>
>
>



 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      14th Feb 2008

Re: "but opens debug and highlights that one line leaves excel open"

Huh...
What line?
There is nothing in your posted code that closes Excel, why wouldn't it still be open?
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"Duane Reynolds 322310"
wrote in message
It runs and executes just fine on my system but opens debug and highlights
that one line leaves excel open
Duane

 
Reply With Quote
 
Duane Reynolds 322310
Guest
Posts: n/a
 
      15th Feb 2008
Sorry next line after that sub is Application.quit but it stalls at
.Documents.Open ("D:\Duane
Docs\Inspection_Report_browser_Merge2008_Fields.doc") with this line
highlighted in yellow in debug.

"Jim Cone" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Re: "but opens debug and highlights that one line leaves excel open"
>
> Huh...
> What line?
> There is nothing in your posted code that closes Excel, why wouldn't it
> still be open?
> --
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
> (Excel Add-ins / Excel Programming)
>
>
> "Duane Reynolds 322310"
> wrote in message
> It runs and executes just fine on my system but opens debug and highlights
> that one line leaves excel open
> Duane
>



 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      15th Feb 2008

Your posted code should be all on one line (not two lines).
If that is not the problem then the file path and/or file name is probably incorrect.
'--
..Documents.Open ("D:\Duane Docs\Inspection_Report_browser_Merge2008_Fields.doc")
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Duane Reynolds 322310"
<(E-Mail Removed)>
wrote in message
Sorry next line after that sub is Application.quit but it stalls at
.Documents.Open ("D:\Duane
Docs\Inspection_Report_browser_Merge2008_Fields.doc") with this line
highlighted in yellow in debug.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Callling a function plus related questions Mark Microsoft Access Getting Started 2 31st May 2006 02:07 PM
Callling DB from Web Link...Bug??? MHiemstra Microsoft Access Form Coding 0 20th Apr 2005 09:56 PM
How do I determine a Function's callling Row Number. Mac Lingo Microsoft Excel Programming 2 26th Aug 2004 02:00 PM
Image in word template wont print fronm outlook Annie Microsoft Outlook Printing 0 14th Jan 2004 02:55 PM
Outlook personal folder lost; can't restore fronm .pst backup =?Utf-8?B?RHIuIGVtYWls?= Microsoft Outlook 1 13th Jan 2004 03:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:44 PM.