Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel printer issue with word mail merge

Status
Not open for further replies.

VbaNewbie08

Technical User
Jun 30, 2008
12
US
The code below runs fine, but for some reason excel default printer wont work any more. The only way to fix it is got to windows change default to another printer and change default back. Any help would be appreciated as i'm some what still new to this.

Sub RunMerge()

Dim wd As Object
Dim wdocSource As Object

Dim strWorkbookName As String

On Error Resume Next
Set wd = GetObject(, "Word.Application")
If wd Is Nothing Then
Set wd = CreateObject("Word.Application")
End If
On Error GoTo 0

Set wdocSource = wd.Documents.Open("P:\Accounts_Payable\Maps Data Import\Labels\Labels.doc")

strWorkbookName = ThisWorkbook.Path & "\" & ThisWorkbook.Name

wdocSource.MailMerge.MainDocumentType = wdFormLetters

wdocSource.MailMerge.OpenDataSource _
Name:=strWorkbookName, _
AddToRecentFiles:=False, _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:="Data Source=" & strWorkbookName & ";Mode=Read", _
SQLStatement:="SELECT * FROM `Labels$`"
wd.ActivePrinter = "\\d922418\HP LaserJet 4 - CABS"
With wdocSource.MailMerge
.Destination = wdSendToPrinter
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With

wd.Visible = True
wd.ActivePrinter = "\\rtprintsrv\NM092PRT15-182"

wdocSource.Close SaveChanges:=False

Set wdocSource = Nothing
Set wd = Nothing


End Sub
 


Hi,

Please re-post this question and post future VBA questions in forum707.

Also please answer what Excel has to do with the printer?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top