Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mailmerge from a button in excel
I am trying to create a mailmerge in excel with the click of a button. When
the button is clicked it opens word sucessfully. Sub OpenWord() Dim wdApp As Object Dim wdDoc As Object Set wdApp = CreateObject("Word.application") Set wdDoc = wdApp.Documents.Open _ (Filename:="C:\Documents and Settings\steve\My Documents\MyTestDoc.doc") wdDoc.Close savechanges:=False Set wdDoc = Nothing wdApp.Quit Set wdApp = Nothing End Sub The code I have placed in Word gives me an error (Ambiguous selection) at the second line .Destination=wdsendToPrinter. Private Sub Document_Open() With ActiveDocument.mailmerge .Destination = wdSendToPrinter .SuppressBlankLines = True With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute Pause:=False End With End Sub I'm making the assumption (new to VBA in excel) that the document is not active but the spreadsheet is and therefore will not print. Not sure how to solve this. If anyone can give me any assistance it would be very much appreciated. Steve Walker |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I perform mailmerge in Excel | Excel Discussion (Misc queries) | |||
Excel Word - Mailmerge | Excel Discussion (Misc queries) | |||
can i use mailmerge to in excel like you would in word? | Excel Discussion (Misc queries) | |||
Mailmerge in Excel? | Excel Programming | |||
VBA mailmerge from Excel | Excel Programming |