Open a word template from access database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I ca npen a Word document but not a specific word template. How do I create
a Command to open a word template
 
To open a word document, create reference (while in code go to tools >
reference) to Microsoft Word and then

Function Open_WordDoc()

Dim objWord As Word.Application
Dim objDoc As Word.Document
Dim DocPath As String

DocPath = "Path and name of the document"

Set objWord = New Word.Application
Set objDoc = objWord.Documents.Open(DocPath)

objDoc.Activate
objDoc.PrintOut ' To print out
objWord.Visible = True ' To display

End Function
 
Beats me I'm afraid

Current Event Procedure to open a specific Word Document is :

Private Sub Command232_Click()
On Error GoTo Err_Command232_Click

Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Documents.Open "N:\Development Control\Planning\High Hedges\Remedial
Notice"
oApp.Visible = True

Exit_Command232_Click:
Exit Sub

Err_Command232_Click:
MsgBox Err.Description
Resume Exit_Command232_Click

Can this be modified to open specific word template?
 
Yes, where do you get the location and file name to open?

Dim Location as String, FileName as String
Dim oApp As Object

Location = "c:\MyDir\"
FileName = "MyFileName.Dot"
Set oApp = CreateObject("Word.Application")
oApp.Documents.Open Location & FileName
oApp.Visible = True ' will open the document

this code will open the file name MyFileName.Dot In the current directory
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck
 
That's brilliant. Works fine. Many thanks

Ofer said:
Yes, where do you get the location and file name to open?

Dim Location as String, FileName as String
Dim oApp As Object

Location = "c:\MyDir\"
FileName = "MyFileName.Dot"
Set oApp = CreateObject("Word.Application")
oApp.Documents.Open Location & FileName
oApp.Visible = True ' will open the document

this code will open the file name MyFileName.Dot In the current directory
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck
 
Back
Top