C
Charles
Jay
I need some help with the subroutine from the article. Do I need a
subroutine for each bookmark, because that is how it appears from the wording
in the brackets - (BookmarkToUpdate As String, TextToUse As String)
This is how my macro looks at present:
Private Sub cmdOK_Click()
Dim strReason As String
Dim strType As String
If optReason1 = True Then strReason = "Actual Exit"
If optReason2 = True Then strReason = "Quotation Only"
If optType1 = True Then strType = "Leaving Service"
If optType2 = True Then strType = "Opting Out (Complete Form 6
Opting-Out)"
If optType3 = True Then strType = "Ill Health Early Retirement (Complete
Form 8 Member's Declaration - Ill Health Retirement)"
If optType4 = True Then strType = "Retirement"
If optType5 = True Then strType = "Death"
Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("bmkID").Range.Text = txtID.Value
.Bookmarks("bmkSur").Range.Text = txtSur.Value
.Bookmarks("bmkTtl").Range.Text = TxtTtl.Value
.Bookmarks("bmkInt").Range.Text = TxtInt.Value
.Bookmarks("bmkNI").Range.Text = txtNI.Value
.Bookmarks("bmkExit").Range.Text = txtExit.Value
.Bookmarks("bmkPay").Range.Text = txtPay.Value
.Bookmarks("bmkAd1").Range.Text = TxtAd1.Value
.Bookmarks("bmkAd2").Range.Text = TxtAd2.Value
.Bookmarks("bmkAd3").Range.Text = TxtAd3.Value
.Bookmarks("bmkAd4").Range.Text = TxtAd4.Value
.Bookmarks("bmkPC").Range.Text = TxtPc.Value
.Bookmarks("bmkSal").Range.Text = txtSal.Value
.Bookmarks("bmkAct").Range.Text = strReason
.Bookmarks("bmkOpt").Range.Text = strType
End With
Application.ScreenUpdating = True
' ActiveDocument.PrintOut Copies:=2
UpdateBookmark "bmkID", txtID.Value
UpdateBookmark "bmkSur", txtSur.Value
UpdateBookmark "bmkTtl", TxtTtl.Value
UpdateBookmark "bmkInt", TxtInt.Value
UpdateBookmark "bmkNI", txtNI.Value
UpdateBookmark "bmkExit", txtExit.Value
UpdateBookmark "bmkPay", txtPay.Value
UpdateBookmark "bmkAd1", TxtAd1.Value
UpdateBookmark "bmkAd2", TxtAd2.Value
UpdateBookmark "bmkAd3", TxtAd3.Value
UpdateBookmark "bmkAd4", TxtAd4.Value
UpdateBookmark "bmkPC", TxtPc.Value
UpdateBookmark "bmkSal", txtSal.Value
UpdateBookmark "bmkAct", strReason
UpdateBookmark "bmkOpt", strType
Unload Me
End Sub
Sub UpdateBookmark(BookmarkToUpdate As String, TextToUse As String)
Dim BMRange As Range
Set BMRange = ActiveDocument.Bookmarks(BookmarkToUpdate).Range
BMRange.Text = TextToUse
ActiveDocument.Bookmarks.Add BookmarkToUpdate, BMRange
End Sub
Thanks
Charles
I need some help with the subroutine from the article. Do I need a
subroutine for each bookmark, because that is how it appears from the wording
in the brackets - (BookmarkToUpdate As String, TextToUse As String)
This is how my macro looks at present:
Private Sub cmdOK_Click()
Dim strReason As String
Dim strType As String
If optReason1 = True Then strReason = "Actual Exit"
If optReason2 = True Then strReason = "Quotation Only"
If optType1 = True Then strType = "Leaving Service"
If optType2 = True Then strType = "Opting Out (Complete Form 6
Opting-Out)"
If optType3 = True Then strType = "Ill Health Early Retirement (Complete
Form 8 Member's Declaration - Ill Health Retirement)"
If optType4 = True Then strType = "Retirement"
If optType5 = True Then strType = "Death"
Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("bmkID").Range.Text = txtID.Value
.Bookmarks("bmkSur").Range.Text = txtSur.Value
.Bookmarks("bmkTtl").Range.Text = TxtTtl.Value
.Bookmarks("bmkInt").Range.Text = TxtInt.Value
.Bookmarks("bmkNI").Range.Text = txtNI.Value
.Bookmarks("bmkExit").Range.Text = txtExit.Value
.Bookmarks("bmkPay").Range.Text = txtPay.Value
.Bookmarks("bmkAd1").Range.Text = TxtAd1.Value
.Bookmarks("bmkAd2").Range.Text = TxtAd2.Value
.Bookmarks("bmkAd3").Range.Text = TxtAd3.Value
.Bookmarks("bmkAd4").Range.Text = TxtAd4.Value
.Bookmarks("bmkPC").Range.Text = TxtPc.Value
.Bookmarks("bmkSal").Range.Text = txtSal.Value
.Bookmarks("bmkAct").Range.Text = strReason
.Bookmarks("bmkOpt").Range.Text = strType
End With
Application.ScreenUpdating = True
' ActiveDocument.PrintOut Copies:=2
UpdateBookmark "bmkID", txtID.Value
UpdateBookmark "bmkSur", txtSur.Value
UpdateBookmark "bmkTtl", TxtTtl.Value
UpdateBookmark "bmkInt", TxtInt.Value
UpdateBookmark "bmkNI", txtNI.Value
UpdateBookmark "bmkExit", txtExit.Value
UpdateBookmark "bmkPay", txtPay.Value
UpdateBookmark "bmkAd1", TxtAd1.Value
UpdateBookmark "bmkAd2", TxtAd2.Value
UpdateBookmark "bmkAd3", TxtAd3.Value
UpdateBookmark "bmkAd4", TxtAd4.Value
UpdateBookmark "bmkPC", TxtPc.Value
UpdateBookmark "bmkSal", txtSal.Value
UpdateBookmark "bmkAct", strReason
UpdateBookmark "bmkOpt", strType
Unload Me
End Sub
Sub UpdateBookmark(BookmarkToUpdate As String, TextToUse As String)
Dim BMRange As Range
Set BMRange = ActiveDocument.Bookmarks(BookmarkToUpdate).Range
BMRange.Text = TextToUse
ActiveDocument.Bookmarks.Add BookmarkToUpdate, BMRange
End Sub
Thanks
Charles