Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    opening word using code (Acc 97 sr2 on 95b)

    I have a code that opens a word document and inserts values.

    The code first checks to see if word is open and then either uses it or opens it.

    If it opens it, it pops up as the front window, but if word is already open, it creates a document without bringing the window to the front.

    What bit of code needs to be added to make an existing background version of word become the open and active window?

    On Error Resume Next
    Set objWord = GetObject(, "Word.Application")
    If Err.Number = 429 Then
    'Word is not running; creating a Word object
    Set objWord = CreateObject("Word.Application")
    Err.Clear
    End If

    ----------
    get values for fields here
    ----------

    objWord.Selection.WholeStory
    objWord.Selection.Fields.Update
    objWord.Selection.HomeKey Unit:=6
    objWord.Visible = True
    objWord.Activate
    "Heading for the deep end"

  2. #2
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Re: opening word using code (Acc 97 sr2 on 95b)

    I've got the answer

    objWord.windowstate = 0

    causes the window to open in the default size

    Just thought I would post the answer for interest sake
    "Heading for the deep end"

Posting Permissions

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