Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions,microsoft.public.word.vba.beginners,microsoft.public.word.vba.userforms
external usenet poster
 
Posts: 14
Default 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.







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I merge data from excel into a Word template? CJ Excel Discussion (Misc queries) 0 August 22nd 06 08:48 PM
Pasting charts to Word from Excel as picture Hari Charts and Charting in Excel 5 July 5th 06 08:04 PM
in an excel macro can you import data from word into a cell? Trefor Excel Discussion (Misc queries) 11 October 6th 05 01:49 PM
Opening two separate instances of Excel Ron Bishop Excel Discussion (Misc queries) 2 August 4th 05 05:30 PM
exporting excel worksheet to word morrowkd Links and Linking in Excel 1 May 11th 05 11:23 PM


All times are GMT +1. The time now is 10:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"