R
Robert_L_Ross
I have a template that I set up that links to a spreadsheet. The userform in
the .dot gets a list of school names from the Excel document, then presents
those in a userform for the user to select. When they select the school, it
populates the bookmarks I set up and the user completes the form. When they
are done, I have a macro/toolbar setup to save the document using some of the
bookmarks inthe document.
Now comes the fun part...if the user wants to complete another form, I want
to open a new document, but then immediately close the saved document.
..dot opens a doc (document1)
User completes document1
User saves document1 as uniquenameddoc1
Macro needs to have .dot open a new doc (document2), then close
uniquenameddoc1
Here's my code:
Sub SaveFormAs()
Dim pFileName As String
pFileName = Year(Now()) & Format(Month(Now()), "00") & _
Format(Day(Now()), "00") & "-" & _
ActiveDocument.FormFields("SchoolName").Result & "-"
& _
ActiveDocument.FormFields("APP_NAME").Result
ActiveDocument.SaveAs "G:\Forms\" & pFileName & ".doc"
End Sub
Sub newform()
Dim CURRENTDOCNAME As String
CURRENTDOCNAME = ActiveDocument.FullName
Word.Documents.Add Template:="G:\forms\Correction Sheet.dot"
Windows(CURRENTDOCNAME).Close
End Sub
This opens the new form, but it doesn't close the old form(s) until I close
my last document.
Am I missing something here?
Thanks!
the .dot gets a list of school names from the Excel document, then presents
those in a userform for the user to select. When they select the school, it
populates the bookmarks I set up and the user completes the form. When they
are done, I have a macro/toolbar setup to save the document using some of the
bookmarks inthe document.
Now comes the fun part...if the user wants to complete another form, I want
to open a new document, but then immediately close the saved document.
..dot opens a doc (document1)
User completes document1
User saves document1 as uniquenameddoc1
Macro needs to have .dot open a new doc (document2), then close
uniquenameddoc1
Here's my code:
Sub SaveFormAs()
Dim pFileName As String
pFileName = Year(Now()) & Format(Month(Now()), "00") & _
Format(Day(Now()), "00") & "-" & _
ActiveDocument.FormFields("SchoolName").Result & "-"
& _
ActiveDocument.FormFields("APP_NAME").Result
ActiveDocument.SaveAs "G:\Forms\" & pFileName & ".doc"
End Sub
Sub newform()
Dim CURRENTDOCNAME As String
CURRENTDOCNAME = ActiveDocument.FullName
Word.Documents.Add Template:="G:\forms\Correction Sheet.dot"
Windows(CURRENTDOCNAME).Close
End Sub
This opens the new form, but it doesn't close the old form(s) until I close
my last document.
Am I missing something here?
Thanks!