Program to Automatically Save Word File

M

maperalia

I have a program that saves as excel and word file with the same filename
(see program below). The excel file is being saved without problem, however,
the word file it is not working at all.

Could you please help me with this matter?.. I think that even the
description I wrote under the word program are completely wrong.

Thanks.
Maperalia


‘*****Start of Program*********
Option Explicit

Public Sub Save()
SaveExcelTemplateAsSaveAs
SaveWordTemplatelAsSaveAs

End Sub

Sub SaveExcelTemplateAsSaveAs()

Dim WO As String
Dim grdprp As String
Dim sFilename As String
Dim Progname As String
Dim Filename As String
Dim myDateTime As String

WO = Worksheets("summary BLR").Range("M10")
myDateTime = Format(Worksheets("summary BLR").Range("M9").Value,
"yyyymmdd")
Filename = "" & WO & "_" & myDateTime & ""
Progname = "C:\Form\" & Filename & ".xls"
ActiveWorkbook.SaveCopyAs Progname
End Sub

'***********OPEN THE TEMPLATE WORD FILE AND SAVE
AS****************************
Sub SaveWordTemplatelAsSaveAs()
Dim wordApp As Object
Dim fNameAndPath As String
Dim Filename As String
Dim WO As String
Dim myDateTime As String

WO = Document("Page 1,Section 1",At 2.1").Range("ln 1,col 2 to ln 1, col
19")
myDateTime = Document("Page 1,Section 1",At 2").Range("ln 2,col 7 to ln
2,col 19")

fNameAndPath = "C:\Word\Template.doc"
Set wordApp = CreateObject("Word.Application")
wordApp.Documents.Open (fNameAndPath)
wordApp.Visible = True
wordApp.Activate

Filename = "" & WO & "_" & myDateTime & ""
Progname = "C:\Form\" & Filename & ".doc"
ActiveDocument..SaveCopyAs Progname



End Sub
'**********************************************************

‘*****End of Program*********
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top