N
nxqviet
Hi,
I use a macro in excel to open an new word application, which then will
open an existing Word document file. Then the excel copy a bunch on
data into the Word document. All that is done, then I need to save this
modified Word document file using a new name (which will generate
automatically). How do I do that? Below is a part of the code I have.
================================
'Generate File Name
Dim varUserName As Variant
Dim varDate As Variant
Dim varFileName As Variant
varUserName = Environ("UserName")
varDate = Format(Date, "yyyymmdd")
varFileName = "varDate & "_" & varUserName
'Create Word Document
Dim WRD As New Word.Application
Dim SOFWR As New Word.Document
Dim strFile As String
strFile = "Template.doc"
Set WRD = New Word.Application
Set SOFWR = WRD.Documents.Open(Filename:="C:\Document\" & strFile)
WRD.Visible = True
......Copy codes...
----> Save as "varFileName" ? <----
======================================
Thanks,
V_
I use a macro in excel to open an new word application, which then will
open an existing Word document file. Then the excel copy a bunch on
data into the Word document. All that is done, then I need to save this
modified Word document file using a new name (which will generate
automatically). How do I do that? Below is a part of the code I have.
================================
'Generate File Name
Dim varUserName As Variant
Dim varDate As Variant
Dim varFileName As Variant
varUserName = Environ("UserName")
varDate = Format(Date, "yyyymmdd")
varFileName = "varDate & "_" & varUserName
'Create Word Document
Dim WRD As New Word.Application
Dim SOFWR As New Word.Document
Dim strFile As String
strFile = "Template.doc"
Set WRD = New Word.Application
Set SOFWR = WRD.Documents.Open(Filename:="C:\Document\" & strFile)
WRD.Visible = True
......Copy codes...
----> Save as "varFileName" ? <----
======================================
Thanks,
V_