M
MarkC
Hi all, Can anyone help please. I have the following macro which runs based
on a selection of 'Y' or 'N' in an excel spreadsheet which opens a word doc
from a word template. My question is how can this be modified to open the
word doc based on the template, but close the actual template once the new
doc is openend. Currently when you save the new document, it also asks if
you wish to save ythe template(basically overwrite), which leave the document
template open to be overtyped!!
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.Add(sFilename)
oWordApp.Visible = True
Set oDoc = Nothing
Set oWordApp = Nothing
End Sub
Private Sub CommandButton1_Click()
End Sub
THANKS ALL
on a selection of 'Y' or 'N' in an excel spreadsheet which opens a word doc
from a word template. My question is how can this be modified to open the
word doc based on the template, but close the actual template once the new
doc is openend. Currently when you save the new document, it also asks if
you wish to save ythe template(basically overwrite), which leave the document
template open to be overtyped!!
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.Add(sFilename)
oWordApp.Visible = True
Set oDoc = Nothing
Set oWordApp = Nothing
End Sub
Private Sub CommandButton1_Click()
End Sub
THANKS ALL