britneyirv
03-28-2016, 12:38 PM
Hello all,
I am new to this forum, well new to posting at least; so if I happen to break any rules, let me know and it won't happen again.
I currently have a huge project of automation I am working on for an accounting firm. I will give a quick explanantion so you all understand the background.
- Excel file for certain #s pertaining to a company that is then put into a graph.
- Button in said Excel file to copy certain graph and post to a Word doc.
- That Word doc consits of a letter that opens at a bookmark to insert the graph.
- Userform pops up & user fills in certain data (Company code, date, quarter or month report)
- After filling out the userform populates certain bookmarks with the information given
- Word doc also has a mail merge list already loaded in
- I want to be able to select a certain mail merge option with a box the user fills in on userform and then make that the active record and fill in the merge fields..
Private Sub CommandButton1_Click()Dim dsMain As MailMergeDataSource
Dim numRecord As Integer
ThisDocument.MailMerge.ViewMailMergeFieldCodes = False
Set dsMain = ThisDocument.MailMerge.DataSource
If dsMain.FindRecord(FindText:=CompanyCode.Text, _
Field:="Company Code") = True Then
numRecord = dsMain.ActiveRecord
End If
Unload Me
End Sub
CompanyCode.Text is my text box where they will input the company code which can be found in the mail merge
The issue is code runs all the way through no issues, but it never actually selects the mail merge record that I want active.
Thank you.
I am new to this forum, well new to posting at least; so if I happen to break any rules, let me know and it won't happen again.
I currently have a huge project of automation I am working on for an accounting firm. I will give a quick explanantion so you all understand the background.
- Excel file for certain #s pertaining to a company that is then put into a graph.
- Button in said Excel file to copy certain graph and post to a Word doc.
- That Word doc consits of a letter that opens at a bookmark to insert the graph.
- Userform pops up & user fills in certain data (Company code, date, quarter or month report)
- After filling out the userform populates certain bookmarks with the information given
- Word doc also has a mail merge list already loaded in
- I want to be able to select a certain mail merge option with a box the user fills in on userform and then make that the active record and fill in the merge fields..
Private Sub CommandButton1_Click()Dim dsMain As MailMergeDataSource
Dim numRecord As Integer
ThisDocument.MailMerge.ViewMailMergeFieldCodes = False
Set dsMain = ThisDocument.MailMerge.DataSource
If dsMain.FindRecord(FindText:=CompanyCode.Text, _
Field:="Company Code") = True Then
numRecord = dsMain.ActiveRecord
End If
Unload Me
End Sub
CompanyCode.Text is my text box where they will input the company code which can be found in the mail merge
The issue is code runs all the way through no issues, but it never actually selects the mail merge record that I want active.
Thank you.