Hi There!
I have two columns of data, one that has a list of bookmarks and another with corresponding data in a workbook. I need to write a macro that looks at the data column, assesses to see if it blank. If it is not blank, it needs to look at the bookmark name and put the data into the word doc.
I have done this on a way more basic level, just telling VBA exactly what the bookmark is named and what range the value should be replaced with, for example:
I am hoping this could be looped and have the modifier for looking for blanks. I tried doing this, but with little success (I am still a serious noob). I appreciate any help or starting points.
Thanks,
Josh
I have two columns of data, one that has a list of bookmarks and another with corresponding data in a workbook. I need to write a macro that looks at the data column, assesses to see if it blank. If it is not blank, it needs to look at the bookmark name and put the data into the word doc.
I have done this on a way more basic level, just telling VBA exactly what the bookmark is named and what range the value should be replaced with, for example:
Code:
Sub Example() Dim ws As Worksheet
Set ws = Sheets("Sheet1")
Dim objword As Object
Dim objDoc As Object
Set objword = CreateObject("Word.Application")
objword.Visible = True
MsgBox "Generating Word Document", vbExclamation, "Word"
Application.ScreenUpdating = False
Set objDoc = objword.Documents.Add("example\path")
With objDoc
.Bookmarks("Example").Range.Text = ws.Range("B3").Value
.Bookmarks("Example2").Range.Text = ws.Range("B4").Value
.Bookmarks("Example3").Range.Text = ws.Range("B7").Value
I am hoping this could be looped and have the modifier for looking for blanks. I tried doing this, but with little success (I am still a serious noob). I appreciate any help or starting points.
Thanks,
Josh