Posts by wedgetail

    Re: Macro to open Word and Start Mail Merge


    Hi MaxDV,


    The information above should be sufficient for you to create the macro.
    I do not know of any complete examples on the net.


    Just try the above code, and if you have any troubles, post a reply and I will try to assist.


    Cheers
    Wedgetail

    Re: Macro to open Word and Start Mail Merge


    CapnAmazing


    If you have set


    with appWd


    above the syntax should be correct.
    The with command keeps the base at that level so you do not need to continually type it.


    Also, have you dimensioned appWD and WdDoc?
    Dim appWd as Word.Application
    Dim WdDoc as Word.Document



    Otherwise, the only other thing you need to check is that the references are set correctly as described earlier.


    Regards
    Wedgatail

    Re: Macro to open Word and Start Mail Merge


    Peter,


    First you need to check that the Word object model is referenced in Excel.
    You do this in Tools - References as per


    1) Open the excel file and Visual Basic Editor
    2) in the VB Editor, go to Tools - References
    3) find and check the Microsoft Word 11.0 Object Library (or something close)


    Second, your code will cause errors to occur.


    When connecting to word, you need to error trap in case word is not open, or is all ready open. Thirdly, it is good practice to dimension all objects and variables before you use them.


    Finally, I think your error has two sources:
    1) Have not referenced the Word Object Model
    2) You have to Mail Merge a Document, Not the application as in your code.


    try


    Dim appWd as Word.Application
    Dim WdDoc as Word.Document


    On Error resume next
    Set appWd = Getobject (,"Word.Application")
    if appWd = nothing then
    Set appWd = Getobject("","Word.Application")
    end if
    on error goto 0


    with appWd
    .visible = True
    set WdDoc = .documents.open Filename:="C:/30DAYLTR - Template1.doc"
    WdDoc.Mailmerge ........
    end with
    set WdDoc = Nothing
    set appWd = Nothing


    Hope that helps
    Wedgetail

    Re: Macro to open Word and Start Mail Merge


    Just a question along very simialar lines to the above.


    Although I can get the macro to run, when word opens/connects to the data file, it takes nearly 1 minute to do its thing. As you need to do this twice [at open then connect to the proper file] the user gets frustrated by having to wait.


    If you just open / connect through word directly, instead of through VBA in excel, the document opens / connects in about 4 - 5 seconds.


    Is there a reason for this, or any way to spead word up?


    Thanks in advance,
    Simon