• Maximizing Word – VBA Code (Access 97/Word 97)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Maximizing Word – VBA Code (Access 97/Word 97)

    Author
    Topic
    #374980

    Help on Maximizing Word

    Green VBAer, really green. Here is some code I conjured up through many different postings that works with what I have. I am trying to mailmerge a record from a query with the click of a button.

    The only downfall on this is that I can’t get Word to maximize, it stays minimized on the bottom of my screen. I added
    objWord.Application.WindowState = wdWindowStateMaximize, but I get a compile error that says variable not defined and points to the “wdWindowStateMaximize” – What do I need to change to make Word be maxmimized?

    Private Sub cmdTest_Click()
    Dim objWord As Object
    Set objWord = GetObject(“d:dataindependent contract.doc”, “word.Document”)
    objWord.Application.Visible = True
    objWord.Application.WindowState = wdWindowStateMaximize
    With objWord
    .Mailmerge.execute
    End With
    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #608469

      Edited by HansV on 14-Aug-02 18:36.

      The simplest way is to use the value instead of the symbolic constant: replace wdWindowStateMaximize by 1. But there is a much better way:

      In your module, select Tools/References…
      In the list of references, look up Microsoft Word 8.0 Object Library
      Check the corresponding box, and click OK.

      Now, Access “knows” Word VBA. Try declaring objWord as

      Dim objWord As Word.Document

      If you type objWord. (note the point/dot), you’ll find that Access provides a list of properties and methods. You may also have to use

      objWord.Application.Activate

      to get Word to be the foreground application.

      • #608470

        Thanks, I’ll give it a try.

      • #608473

        Thanks a million. That fixed my problem.

        For other green VBAer’s – here the code that ended up working for me to merge an access query to Word.

        Private Sub cmdTest_Click()
        Dim objWord As Word.Document
        Set objWord = GetObject(“d:dataindependent contract.doc”, “Word.Document”)
        objWord.Application.Visible = True
        objWord.Application.WindowState = wdWindowStateMaximize
        objWord.MailMerge.Execute

        End Sub

    Viewing 0 reply threads
    Reply To: Reply #608470 in Maximizing Word – VBA Code (Access 97/Word 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel