Creating a Word Document from Access and then closing Word

  • 14 years ago

    This is what I'm trying to do -

    Open a Word doc from Access (event of a command button). This opens a .dot Word template file, which the user then goes on to edit and ideally, when coming to Save it, the file will have automatically switched to a .doc file, which is what happens normally in Word. However, when opening the Word file from Access, the file does not automatically change to a .doc file, as if Access still has some hold over the file. The code I used to open the Word doc is below:

    Sub OpenWordDoc(strDocName As String)
    Dim objApp As Object

    'Opens the document

    Set objApp = CreateObject("Word.Application")
    objApp.Visible = True
    objApp.Documents.Open strDocName
    End Sub

    Call OpenWordDoc([filename])

    Another problem is that if I try to close the Word program that has been opened via Access, I got an error message saying something like:

    'File normal.dot still in use by another program....'

    I temporarily resolved this by deleting the Normal.dot file, but I suspect the problem will re-emerge if not dealt with in another way!

    Anyone have any ideas?





















    Edit/Delete Message

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only two kinds of languages: the ones people complain about and the ones nobody uses” - Bjarne Stroustrup