ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help required to debug mailmerge procedure (https://www.excelbanter.com/excel-programming/314481-help-required-debug-mailmerge-procedure.html)

JRB

Help required to debug mailmerge procedure
 
I am attempting to run a mailmerge from Excel (Office 97) using the
following procedu
It doesn't work .... and I am tearing my hair out - please help before I am
completely bald
TIA

..............
Sub PrintLabels()

Dim WD As Object

Set WD = CreateObject("Word.Application")
WD.Application.DisplayAlerts = wdAlertsNone
WD.Documents.Open (ThisWorkbook.Path & "\BDayList Labels.doc")
WD.ActiveDocument.Mailmerge.Destination = wdSendToPrinter
WD.ActiveDocument.Mailmerge.Execute
WD.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
WD.Application.DisplayAlerts = wdAlertsAll
WD.Quit SaveChanges:=wdDoNotSaveChanges
Set WD = Nothing

End Sub
..............



Tom Ogilvy

Help required to debug mailmerge procedure
 
Do you have a reference set to the Word Object Library in the Excel VBE
under the References menu

--
Regards,
Tom Ogilvy

"JRB" wrote in message
...
I am attempting to run a mailmerge from Excel (Office 97) using the
following procedu
It doesn't work .... and I am tearing my hair out - please help before I

am
completely bald
TIA

.............
Sub PrintLabels()

Dim WD As Object

Set WD = CreateObject("Word.Application")
WD.Application.DisplayAlerts = wdAlertsNone
WD.Documents.Open (ThisWorkbook.Path & "\BDayList Labels.doc")
WD.ActiveDocument.Mailmerge.Destination = wdSendToPrinter
WD.ActiveDocument.Mailmerge.Execute
WD.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
WD.Application.DisplayAlerts = wdAlertsAll
WD.Quit SaveChanges:=wdDoNotSaveChanges
Set WD = Nothing

End Sub
.............





JRB

Help required to debug mailmerge procedure(2)
 
I have the following references set up (not sure whether they were set up
when I posted original request)

Visual Basic for Applications
Microsoft Excel 8.0 Object Library
OLE Automation
Microsoft Word 8.0 Object Library
Microsoft Office 8.0 Object Library
Microsoft Forms 2.0 Object Library

I have been testing with only one page of labels to be printed and although
the procedure now seems to work it takes a long time ... in fact I get an
Message box displayed saying:
"Task is taking longer than expected Do you want to continue ?"

On other occasions I have received the message "Excel is waiting for another
application to complete an OLE action" and I eventually have to resort to
Task manager to end either the Print process or Word before I can regain
control of the spreadsheet

Have you any suggestions re speeding up the process
I am using WinXP and Office97 on P3 with 256Mb RAM

Regards and thanks
Jim Burton

"JRB" wrote in message
...
I am attempting to run a mailmerge from Excel (Office 97) using the
following procedu
It doesn't work .... and I am tearing my hair out - please help before I

am
completely bald
TIA

.............
Sub PrintLabels()

Dim WD As Object

Set WD = CreateObject("Word.Application")
WD.Application.DisplayAlerts = wdAlertsNone
WD.Documents.Open (ThisWorkbook.Path & "\BDayList Labels.doc")
WD.ActiveDocument.Mailmerge.Destination = wdSendToPrinter
WD.ActiveDocument.Mailmerge.Execute
WD.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
WD.Application.DisplayAlerts = wdAlertsAll
WD.Quit SaveChanges:=wdDoNotSaveChanges
Set WD = Nothing

End Sub
.............






All times are GMT +1. The time now is 11:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com