Hash86
09-23-2013, 12:02 AM
Hey everyone.
I'm very new with VBA, so hoping to get some help here..
10605
Here I have my bookmarks set.
I can enter in the details into the bookmarks just fine.
What I want, however, is for the second address bookmark (where the suburb goes) to be deleted and be replaced by the city and post code.
My code is this:
With ActiveDocument
' Set up the letter details
' Parent's name
.Bookmarks("Text1").Range.Text = TBP1Name
' Parent's address
.Bookmarks("Text2").Range.Text = TBP1Add1
If .Bookmarks("text3") = "" Then
.Bookmarks("text3").Delete
.Bookmarks("text4").Range.Text = TBCity + ", " + TBPostCode
Else
.FormFields("text3").Range.Text = TBSuburb
.FormFields("text4").Range.Text = TBCity + ", " + TBPostCode
End If
End With
where:
"Text1" = Parent's name
"Text 2" = Address line 1
"Text 3" = Address line 2
"Text 4" = City and Post code
What this comes up with is this:
Homer Simpson
742 Evergreen Terrace
Montana, 1234
But I want this:
Homer Simpson
742 Evergreen Terrace
Montana, 1234
Any help would be greatly appreciated! Thanks
Oh, while we're here, my form asks for "Parent's name" - both first and last name.
Any way of just putting the parent's first name only after the "Dear" in the first line of the letter?
Thanks in advance :)
I'm very new with VBA, so hoping to get some help here..
10605
Here I have my bookmarks set.
I can enter in the details into the bookmarks just fine.
What I want, however, is for the second address bookmark (where the suburb goes) to be deleted and be replaced by the city and post code.
My code is this:
With ActiveDocument
' Set up the letter details
' Parent's name
.Bookmarks("Text1").Range.Text = TBP1Name
' Parent's address
.Bookmarks("Text2").Range.Text = TBP1Add1
If .Bookmarks("text3") = "" Then
.Bookmarks("text3").Delete
.Bookmarks("text4").Range.Text = TBCity + ", " + TBPostCode
Else
.FormFields("text3").Range.Text = TBSuburb
.FormFields("text4").Range.Text = TBCity + ", " + TBPostCode
End If
End With
where:
"Text1" = Parent's name
"Text 2" = Address line 1
"Text 3" = Address line 2
"Text 4" = City and Post code
What this comes up with is this:
Homer Simpson
742 Evergreen Terrace
Montana, 1234
But I want this:
Homer Simpson
742 Evergreen Terrace
Montana, 1234
Any help would be greatly appreciated! Thanks
Oh, while we're here, my form asks for "Parent's name" - both first and last name.
Any way of just putting the parent's first name only after the "Dear" in the first line of the letter?
Thanks in advance :)