S
singeredel
I am trying to insert variable information into multiple bookmarks with the
following code. However, I get the following compile error: "With Object must
be user-defined type, Object, or Variant." Can anyone tell me what I am
missing? Is there is a better way to do this? Thanks!
Dim bBkm As String
Dim bText As String
Dim bIndex As Long
For bIndex = 1 To 5
bBkm = Choose(bIndex, "Address1", "Address2", "Address3", "Address4",
"Address5")
bText = Choose(bIndex, ReportAddress1$, ReportAddress2$,
ReportAddress3$, _
ReportAddress4$, ReportAddress5$)
If bIndex = 4 Or bIndex = 5 Then
Selection.Paragraphs.Style = "Normal"
End If
With ActiveDocument.Bookmarks(bIndex).Range.Text = bText
If bIndex = 4 Or bIndex = 5 Then
If bText = "" Then
ActiveDocument.Bookmarks(bIndex).Select
Selection.Delete Count:=1
End If
End If
End With
Next
End With
following code. However, I get the following compile error: "With Object must
be user-defined type, Object, or Variant." Can anyone tell me what I am
missing? Is there is a better way to do this? Thanks!
Dim bBkm As String
Dim bText As String
Dim bIndex As Long
For bIndex = 1 To 5
bBkm = Choose(bIndex, "Address1", "Address2", "Address3", "Address4",
"Address5")
bText = Choose(bIndex, ReportAddress1$, ReportAddress2$,
ReportAddress3$, _
ReportAddress4$, ReportAddress5$)
If bIndex = 4 Or bIndex = 5 Then
Selection.Paragraphs.Style = "Normal"
End If
With ActiveDocument.Bookmarks(bIndex).Range.Text = bText
If bIndex = 4 Or bIndex = 5 Then
If bText = "" Then
ActiveDocument.Bookmarks(bIndex).Select
Selection.Delete Count:=1
End If
End If
End With
Next
End With