Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Problem sending merge info to printer

I am running Office apps (Word, Excel) 2002 SP3 and Win XP Home.

I have a primary Excel workbook that opens a Word document using a second
Excel workbook for data.

In the primary Excel file, I want to click a button that opens a mail merge
Word document, determine the records I want printed (from the second Excel
file) and print them. I can accomplish all of these tasks but when asked to
print, the records are not sent to the printer. Here's more info...

Portions of the code I use are as follows:

Initial declaration...
Dim PreOpForm As Object, WordDoc As Object
Set PreOpForm = CreateObject("Word.Application")
Set WordDoc = CreateObject("Word.Document")
..
..

Code to open second Excel file...
Workbooks.Open Filename:="Z:\Office\Forms\Forms\Miscellaneous\Sur gery
Schedule.xls"
..
..

Code to open Word document...
Set WordDoc = PreOpForm.Documents.Open("Z:\Office\Progress Notes\Pre &
Postop Forms\Surgery Packet\€¢ Pre-Op Packet Cover Sheet.doc")
..
..

Code to merge and print...
Function SpoolToPrint()
'
Application.ScreenUpdating = False
PreOpForm.Visible = True
PreOpForm.WindowState = xlMinimized
PreOpForm.Activate
'
' Setting the records of the patient(s) in the surgery schedule to mail
merge
InitialRecord = InitialRecord - 1
NumberOfRecords = NumberOfRecords - 1
With WordDoc.MailMerge
.Destination = wdSendToPrinter
.SuppressBlankLines = True
With .DataSource
.FirstRecord = InitialRecord
.LastRecord = InitialRecord + NumberOfRecords
End With
.Execute Pause:=False
End With
'
WordDoc.Close
'
Application.ScreenUpdating = True
End Function

I obtained the merge code by creating a macro to merge info and then looking
at the macro code. I have stepped through the code and the problem I
encounter is this:
When the line '.Execute Pause:=False' is run, instead of the appropriate
merged records getting forwarded to the printer, a new MS Word document is
opened (regardless of how many records are merged only 1 Word document is
opened) as a copy of the original file but with the merged info present. The
title of the new document is "Form Letters1.doc".

I have searched this NG for answers, checked the internet and searched more
help files than I care to elaborate on and cannot find a solution.

In addition, I can't explain that after executing the 'PreOpForm.Activate'
code, the ActiveWorkbook.Name is the main Excel file not the Word file. I
cannot seem to activate the Word file with the merged info to print it using
'Printout'. If I could, I can always set up a For..Next routine to merge
individual records and print them using 'Printout'. How can I do that if
"PreOpForm.Activate" doesn't give focus to the Word document with the merged
info? It gives focus to the Word ducmnet with the mergefields, not the
merged data. I would much prefer to try and get the 'execute' statement to
work.

Any assistance is greatly appreciated. Thanks in advance.

Boog

Reply
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
Save default printer info in Excel JJRamCHS Excel Discussion (Misc queries) 0 April 27th 07 10:54 PM
E-Mail Merge difficulties--not actually sending? [email protected] Excel Worksheet Functions 0 January 23rd 06 04:16 PM
Sending Info jsnider Excel Worksheet Functions 2 October 15th 05 08:25 PM
How do I turn off info box "This document was sent to the printer. blangkamp Excel Discussion (Misc queries) 0 March 7th 05 02:23 PM
Sending print commands to the printer Brady Snow Excel Programming 1 November 3rd 03 11:41 PM


All times are GMT +1. The time now is 03:55 PM.

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

About Us

"It's about Microsoft Excel"