Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2010
    Posts
    12

    Open Word Doc in foreground

    I created a command button that opens a MS Word Doc from my database using the following code:

    Dim oApp As Object
    Dim strDocName As String

    strDocName = "E:\Patrick\Bids\Selling Points\Estimate Pipeline Insp"
    Set oApp = CreateObject("Word.Application")


    oApp.Visible = True
    oApp.Documents.Open strDocName

    Problem is, it opens in the background. How do I make this open in the foreground?

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Thy this code.This will open your word document in the foreground.

    Private Sub Command1_Click()

    Dim LWordDoc As String
    Dim oApp As Object

    'Path to the word document
    LWordDoc = "E:\Patrick\Bids\Selling Points\Estimate Pipeline Insp"

    If Dir(LWordDoc) = "" Then
    MsgBox "Document not found."

    Else
    'Create an instance of MS Word
    Set oApp = CreateObject(Class:="Word.Application")
    oApp.Visible = True

    'Open the Document
    oApp.Documents.Open filename:=LWordDoc
    End If

    End Sub

    Please mark this thread solved if this solves your problem.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access and Word Automation
    By djreyrey in forum Forms
    Replies: 1
    Last Post: 01-08-2010, 02:33 PM
  2. Replies: 1
    Last Post: 06-04-2009, 07:43 AM
  3. how do i do a word count
    By clueless in forum Queries
    Replies: 0
    Last Post: 06-03-2009, 09:01 PM
  4. access to word please help!
    By fiesta_rich in forum Import/Export Data
    Replies: 2
    Last Post: 04-14-2009, 09:27 PM
  5. How do I specify a version of Word using CreateObject?
    By TrevorOlding in forum Programming
    Replies: 1
    Last Post: 03-17-2006, 12:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums