Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Aug 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Maximizing Word - VBA Code (Access 97/Word 97)

    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

  2. #2
    New Lounger
    Join Date
    Aug 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Maximizing Word - VBA Code (Access 97/Word 97)

    Thanks, I'll give it a try.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Maximizing Word - VBA Code (Access 97/Word 97)

    <P ID="edit" class=small>Edited by HansV on 14-Aug-02 18:36.</P>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.

  4. #4
    New Lounger
    Join Date
    Aug 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Maximizing Word - VBA Code (Access 97/Word 97)

    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

Posting Permissions

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