B
blanic via AccessMonster.com
Here is my code, it opens both as new files instead of opening the template
and adding the document
I have also reversed the add and open lines to see if it made a difference,
same results.
Dim wdApp As Word.Application
Dim doc As Word.Document
Dim strTemplate As String
Dim RetVal
Dim TheDate As String ' Declare variables.
Dim Today As String
Dim Year As String
Dim Yar As String
Dim month As String
Dim Mont As String
Dim fs As New FileSystemObject
Dim SourceFile, DestinationFile
TheDate = Now
Today = DatePart("d", TheDate)
Year = DatePart("yyyy", TheDate)
Yar = Right(Year, 2)
month = DatePart("m", TheDate)
Mont = rtnMonth(month)
Set wdApp = New Word.Application
wdApp.Visible = True
strTemplate = "E:\CGInst\Rpts\COSIG.dot"
Set doc = wdApp.Documents.Open(strTemplate)
Set doc = wdApp.Documents.Add("E:\CGinst\RPTS\" + Yar + "\" + Mont + "\2300."
+ Today)
With wdApp.ActiveDocument.PageSetup
.TopMargin = InchesToPoints(0.35)
.BottomMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
.LeftMargin = InchesToPoints(0.25)
End With
Set ftRng = wdApp.ActiveDocument.Content
With ftRng.Font
.Bold = True
End With
and adding the document
I have also reversed the add and open lines to see if it made a difference,
same results.
Dim wdApp As Word.Application
Dim doc As Word.Document
Dim strTemplate As String
Dim RetVal
Dim TheDate As String ' Declare variables.
Dim Today As String
Dim Year As String
Dim Yar As String
Dim month As String
Dim Mont As String
Dim fs As New FileSystemObject
Dim SourceFile, DestinationFile
TheDate = Now
Today = DatePart("d", TheDate)
Year = DatePart("yyyy", TheDate)
Yar = Right(Year, 2)
month = DatePart("m", TheDate)
Mont = rtnMonth(month)
Set wdApp = New Word.Application
wdApp.Visible = True
strTemplate = "E:\CGInst\Rpts\COSIG.dot"
Set doc = wdApp.Documents.Open(strTemplate)
Set doc = wdApp.Documents.Add("E:\CGinst\RPTS\" + Yar + "\" + Mont + "\2300."
+ Today)
With wdApp.ActiveDocument.PageSetup
.TopMargin = InchesToPoints(0.35)
.BottomMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
.LeftMargin = InchesToPoints(0.25)
End With
Set ftRng = wdApp.ActiveDocument.Content
With ftRng.Font
.Bold = True
End With