![]() |
Excel VBA printing to MS Word cause MS Word to crash, why?
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 -- alruf ----------------------------------------------------------------------- alruff's Profile: http://www.excelforum.com/member.php...fo&userid=1500 View this thread: http://www.excelforum.com/showthread.php?threadid=26623 |
All times are GMT +1. The time now is 01:40 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com