StephenBart
New Member
- Joined
- Jun 22, 2023
- Messages
- 15
- Office Version
- 365
- Platform
- Windows
I have a macro enabled workbook to produce cost estimates for customer proposals. I have built a macro in cost estimate workbook to create a customer specific proposal in word from a word template that uses mail merge fields to pull in the data from various cells in the cost estimate workbook, and save the proposal with certain filename syntax and path based on cell values in the cost estimate workbook. The macro works great.
Sub CreateVIProposal()
'
' Creates Proposal Document for JPVI
'
Dim iApp As Word.Application
Dim iDoc As Word.Document
Dim FileName As String
Dim Path As String
Path = Range("c58") & "\"
FileName = Range("c61")
Set iApp = CreateObject("Word.Application")
iApp.Visible = True
iApp.Activate
Set iDoc = iApp.Documents.Add(Template:="U:\1000 ADMIN\1990 Templates\PROP_to_LlllFf_by_BartSt_re_CustNa-Street-Cit_RS_nx_YYYYMMDD_rev1.dotm", NewTemplate:=False, DocumentType:=0)
iDoc.SaveAs2 FileName:=Path & FileName & ".docm", FileFormat:=wdFormatXMLDocument, AddtoRecentFiles:=False
End Sub
I need a macro in the cost estimate work book to open the macro enabled word document created above, in so doing update the merge fields, and then I would like to save a pdf of section s5 only (I use section breaks in the word document) the pdf will be saved in the same path but with different filename FileName = Range("c62"). I would like the word document to remain open and idealy navigated to s5.
Can anyone help me
Sub CreateVIProposal()
'
' Creates Proposal Document for JPVI
'
Dim iApp As Word.Application
Dim iDoc As Word.Document
Dim FileName As String
Dim Path As String
Path = Range("c58") & "\"
FileName = Range("c61")
Set iApp = CreateObject("Word.Application")
iApp.Visible = True
iApp.Activate
Set iDoc = iApp.Documents.Add(Template:="U:\1000 ADMIN\1990 Templates\PROP_to_LlllFf_by_BartSt_re_CustNa-Street-Cit_RS_nx_YYYYMMDD_rev1.dotm", NewTemplate:=False, DocumentType:=0)
iDoc.SaveAs2 FileName:=Path & FileName & ".docm", FileFormat:=wdFormatXMLDocument, AddtoRecentFiles:=False
End Sub
I need a macro in the cost estimate work book to open the macro enabled word document created above, in so doing update the merge fields, and then I would like to save a pdf of section s5 only (I use section breaks in the word document) the pdf will be saved in the same path but with different filename FileName = Range("c62"). I would like the word document to remain open and idealy navigated to s5.
Can anyone help me