Opening a Word Template from within Excel
Declare wordDot as document, open it as template.
Look at below code.
Btw, are you sure to open as template ??
Dim wordApp As Word.Application
Dim wordDot As Word.Document
Dim sPath As String
Set wordApp = New Word.Application
sPath = "\\Network\Products\Clients\Orders.dot"
On Error Resume Next
With wordApp
.Visible = True
Set wordDot = _
.Documents.Open(FileName:=sPath, _ &
ReadOnly:=False, Format:=wdFormatTemplate)
--
Krgrds,
Perry
"Doctorjones_md" wrote:
Tony -- thanks for the quick reply ...
I'd already tried the following (Word application opened, but the document
(Order.dot) didn't -- any ideas as to why?
Private Sub cmdManaged_Click()
'opens a new Word Template
Dim wordApp As Word.Application
Dim wordDot As Word.Template
Set wordApp = New Word.Application
On Error Resume Next
With wordApp
.Visible = True
Set wordDot =
.Documents.Open("\\Network\Products\Clients\Orders .dot", , False)
End With
Unload Me
End Sub
"Tony Jollans" <My forename at my surname dot com wrote in message
...
The template opens because that's what you have coded ...
documents.OPEN(etc.....
What you want to do is add a new document based on the template ...
documnets.ADD("whatever.dot", ....
Clicking on a document (.doc file) or template (.dot file) or any other
file type causes the default action for that file type to be invoked. The
default for documents is "Open"; the default for templates is "New" (i.e.
create a new document based on the template)
--
Enjoy,
Tony
"Doctorjones_md" wrote in message
...
I have the following VBA code with opens a Word Template (.dot extension)
from Excel:
1. CommandButton1 code on worksheet --
Private Sub CommandButton1_Click()
SQLRollup
DeleteBlankRows
RollupToSQLServer1
InsertTrackingSpecificData
frmClients.Show
End Sub
2. Code on frmClients
Private Sub cmdProposal_Click()
frmOrders.Show
frmClients.Hide
End Sub
3. Code on frmOrders
Private Sub cmdManaged_Click()
'opens a new Word Template
Dim wordApp As Word.Application
Dim wordDot As Word.Template
Set wordApp = New Word.Application
On Error Resume Next
With wordApp
.Visible = True
Set wordDot =
.Documents.Open("\\Network\Products\Clients\Orders .dot", , False)
End With
Unload Me
End Sub
==============================================
The problem I'm having is that the code in item#3 opens the template
without forcing a new Document1 -- therefore, the template get
over-written by any modifications made while in use. What's curious is
that when I navigate to the Order.dot file (outside of Excel) and CLICK
on it, a Document1 is created.
How can I modify the code to do (from within Excel) what simply openning
the file from Explorer does?
Thanks in advance for any and all suggestions/recommendations.
|