+ Reply to Thread
Results 1 to 9 of 9

[SOLVED] Mailmerge from a button in excel

Hybrid View

  1. #1
    Kassie
    Guest

    RE: Mailmerge from a button in excel

    Shouldn't you do this from Word?

    "stevew" wrote:

    > 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
    >
    >
    >


  2. #2
    stevew
    Guest

    Re: Mailmerge from a button in excel

    Trying not to. I want to mail letters for the data in excel but use excel as
    the main application.

    Steve

    "Kassie" <j.kasselman@ATlantic.net.removeAT> wrote in message
    news:AE449429-CF60-47A3-9944-A69D52EE07D5@microsoft.com...
    > Shouldn't you do this from Word?
    >
    > "stevew" wrote:
    >
    >> 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
    >>
    >>
    >>




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1