Excel VBA printing to MS Word cause MS Word to crash, why?

A

alruff

I have an excel file that I use to print 4 documents for each lin
(5000) in the Excel worksheet.

This entire action is automated via VBA code. The first two document
printed are Excel worksheet documents, the 3rd is an MS Word file, an
the 4th is an Excel worksheet document.

I wrote the initial application is Office 2002 and it works fine i
2002. I am now required to make it work in Office 2000, but crashes M
Word in Office 2000.

The MS Word document contains field codes that are updated fro
specific cells in the Excel Worksheet. MS Word Print Options are se
to Update Links, Update Field codes, and no background printing.

The first 6 Excel lines process fine beofe MS Word crashes. I receiv
a message "MS Word for Windows has encountered a problem and needs t
close:" The Error code is:

AppName: winword.exe AppVer: 9.0.0.3822 Offset: 000f3a53.

Excel has a window open indicating that "Microsoft Excel is waiting fo
another application to complete an OLE object". Click "Send" or Don'
Send" in the MS Word error closes Word, and Excel then produces
run-time error '-2147023170 (800706be)' Automation error The remot
procedure call failed.

The debug line reads as follows:

wdApp.activedocument.PrintOut Background:=False, Copies:=1
Collate:=True


My entire Excel vba word code looks like this:

Dim wdApp As Object
Dim wdDoc As Object

Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.documents.Open("C:\FormR1.doc")

Do Until Worksheets("DB").Cells(i, 1).Value = ""

Worksheets("AddrSheet").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

Worksheets("Cover").Activate
Application.CalculateFull
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

wdApp.activedocument.PrintOut Background:=False, Copies:=1
Collate:=True
Worksheets("FormA").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

i = i + 1
Loop


Any ideas why this crashes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top