Open particular word document from access - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Open particular word document from access

micks_guptamicks_gupta Posts: 8Member
hi,

My problem is that i want to open a particular word document from form in access database. i.e. when user clicks on open command button a predecided mail merge word document should open.

it allows to open Microsoft word but not a particular document.
if anybody can help out pls.

thanks
micks

Comments

  • dokken2dokken2 Posts: 532Member
    : hi,
    :
    : My problem is that i want to open a particular word document from form in access database. i.e. when user clicks on open command button a predecided mail merge word document should open.
    :
    : it allows to open Microsoft word but not a particular document.
    : if anybody can help out pls.
    :
    : thanks
    : micks
    :

    Use automation, requires a reference to the MS word library-

    [code]
    Option Explicit

    'MODULE, TOOLS, REFERENCES..., must set a ref. to-
    'microsoft word 10.0 object library
    Dim WordApp As Word.Application
    Const MyDoc = "e:doc1.doc"


    Private Sub Command1_Click()
    'init word object
    Set WordApp = New Word.Application
    'show word
    WordApp.Application.Visible = True
    'open word file
    WordApp.Documents.Open MyDoc
    End Sub

    Private Sub Command2_Click()
    'save document
    WordApp.Documents.Item(MyDoc).Save
    'close document
    WordApp.Documents.Item(MyDoc).Close False
    'quit word
    WordApp.quit
    'release resouces
    Set WordApp = Nothing
    End Sub

    [/code]
  • splansingsplansing Posts: 140Member
    : : hi,
    : :
    : : My problem is that i want to open a particular word document from form in access database. i.e. when user clicks on open command button a predecided mail merge word document should open.
    : :
    : : it allows to open Microsoft word but not a particular document.
    : : if anybody can help out pls.
    : :
    : : thanks
    : : micks
    : :
    :
    : Use automation, requires a reference to the MS word library-
    :
    : [code]
    : Option Explicit
    :
    : 'MODULE, TOOLS, REFERENCES..., must set a ref. to-
    : 'microsoft word 10.0 object library
    : Dim WordApp As Word.Application
    : Const MyDoc = "e:doc1.doc"
    :
    :
    : Private Sub Command1_Click()
    : 'init word object
    : Set WordApp = New Word.Application
    : 'show word
    : WordApp.Application.Visible = True
    : 'open word file
    : WordApp.Documents.Open MyDoc
    : End Sub
    :
    : Private Sub Command2_Click()
    : 'save document
    : WordApp.Documents.Item(MyDoc).Save
    : 'close document
    : WordApp.Documents.Item(MyDoc).Close False
    : 'quit word
    : WordApp.quit
    : 'release resouces
    : Set WordApp = Nothing
    : End Sub
    :
    : [/code]
    :
    Or, if you want to save a bit of hassle, just set the hyperlink property of your button to the name (including the path) of the document you want to open. You can do this in the button's property sheet or using code (FollowHyperLink command).
Sign In or Register to comment.