LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error controlling Word from Excel

Hi,

I wrote a simple (I thought) macro to populate a Word document from
Excel (both are Office 2003). I seem to be doing something wrong at
the end of the macro when I kill off the Word object, because the
macro appears to work fine the first time I invoke it and then fails
the next time with the error message "Run-time error '462': The remote
server machine does not exist or is unavailable." I then have to go
into the Task Manager and manually kill the Winword process. When I
do this, I can then run the macro again--once--before getting the
error again the second time I run it. It's frustrating, and I'd
really appreciate it if anyone can lend their wisdom and help me make
it fully functional.

Here's the applicable code (repetitive code in the middle has been
removed for clarity):

Sub Populate_Report()

Dim WordApp As New Word.Application

Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Open ("C:\Report.doc")

Word.ActiveDocument.Bookmarks("Name").Select 'NOTE: This is the
indicated line when the macro breaks
Word.Selection.TypeText NameValue
....

Word.ActiveDocument.SaveAs Filename:="C:\" & ReportName & ".doc"

WordApp.Quit
Set WordApp = Nothing

My thanks to anyone who can help me.

Best wishes...

....Jay
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Controlling MS Word from VBA Excel danp_db Excel Programming 2 October 31st 05 04:04 PM
Error while controlling Word from Excel JFamilo[_11_] Excel Programming 4 August 15th 05 01:58 AM
Controlling Word from Excel Paul Haywood Excel Programming 3 June 30th 04 11:13 AM
Controlling Word from Excel tonesmcbutt Excel Programming 1 January 7th 04 09:21 PM


All times are GMT +1. The time now is 08:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"