Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2007

Tip: Looking for answers? Try searching our database.

creating word doc from a word template by macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MarkC - 07 Jun 2007 13:35 GMT
Can anyone help please, I have an excel spreadheet that when a cell is
controlled by a Y or N answer only, it selects a word document to complete.
This form shoudl be created from a template in the normal way word does, but
my macro is simply opening the template (.dot file openining, not a .doc
file), not creating from the template.  Can anyone help as to how I can
achive this by modifying the VBA below.

Sub GetWordDocument()
Dim oWordApp As Object
Dim oDoc As Object
Dim sFilename As String

   Set oWordApp = CreateObject("Word.Application")
   If Range("G3").Value = "Y" Then
       sFilename = "M:\001_Quality\Manual advice Notes\Template\ST011AFO
Issue 1 Advice note AND Customs invoice.dot"
   Else
       sFilename = "M:\001_Quality\Manual advice Notes\Template\ST011FO
Issue 4 Manual Advice Note.dot"
   End If
   Set oDoc = oWordApp.Documents.Open(sFilename)
   oWordApp.Visible = True
   Set oDoc = Nothing
   Set oWordApp = Nothing
End Sub

Private Sub CommandButton1_Click()

End Sub

thank you
Jean-Guy Marcil - 07 Jun 2007 15:09 GMT
MarkC was telling us:
MarkC nous racontait que :

> Can anyone help please, I have an excel spreadheet that when a cell is
> controlled by a Y or N answer only, it selects a word document to
[quoted text clipped - 27 lines]
>
> thank you

Change

   Set oDoc = oWordApp.Documents.Open(sFilename)

to

   Set oDoc = oWordApp.Documents.Add(sFilename)

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.