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.

VBA help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MarkC - 07 Jun 2007 11:52 GMT
Can anyone help please, I have the macro below which selects 1 of 2 forms
based on critera in an excel spreadsheet cell.  What is not happeneing , is
that a normal word doc should open from the word template its based on. But
the macro below opens the .dot template....not creating a doc from the
template.

can anyone help please!.

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
Helmut Weber - 07 Jun 2007 12:03 GMT
Hi Mark,

apart from other issues,
it is
documents.add
not
documents.open

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Pranav Vaidya - 12 Jun 2007 17:17 GMT
Try using the Documents.add method.
Also please check where is the template code, it should be in New method

With add method above, the code in New will automatically get executed.

Regards.

> Can anyone help please, I have the macro below which selects 1 of 2 forms
> based on critera in an excel spreadsheet cell.  What is not happeneing , is
[quoted text clipped - 26 lines]
>
> End Sub
 
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.