J
John G.
Putting together an entertainment agreement doc. Using a userform for the
varible information that I have bookmarked in the doc. I'll admit I'm a
novice at VBA so any help is appreciated.
I'm getting a "Compiler Error: ByRef argument type mismatch" error when I go
to run the UpdateBookmark sub (I got this from the MVP FAQ by Dave Rado).
The sub worked OK when I used the simple formated date value in a
"mm/dd/yyyy" format. But I need a ordinal day format "17th day of August
2009" which I produce in the calendar sub.
I'm using linked textboxes to flow the contractor info (reason for
concatenating), the services, and the compensation info in the doc. The
bookmarks are in the first textbox of each linked group.
I'm loading the doc with data when the "cmbFinish" button is clicked to give
the user the ability to review the info on the userform before the transfer.
Thx in advance. John G
-------------------------------
Public ContrInfoCombo, FormalDt, OrdinalDay As String
Private Sub cmbDate_Click()
With Calendar1
.Value = Date
.Visible = True
End With
Repaint
End Sub
Private Sub Calendar1_Click()
cmbDate.Visible = False
tbAgreeDt.Value = Format(Calendar1.Value, "mm/dd/yy")
Calendar1.Visible = False
lblLine.Visible = True
Select Case Day(tbAgreeDt.Value)
Case 1, 21, 31
OrdinalDay = Str(Day(tbAgreeDt.Value)) + "st"
Case 2, 22
OrdinalDay = Str(Day(tbAgreeDt.Value)) + "nd"
Case 3, 23
OrdinalDay = Str(Day(tbAgreeDt.Value)) + "rd"
Case Else
OrdinalDay = Str(Day(tbAgreeDt.Value)) + "th"
End Select
FormalDt = OrdinalDay + " day of " + Format(tbAgreeDt.Value, "MMMM yyyy")
End Sub
Private Sub tbContrPh_AfterUpdate()
ContrInfoCombo = tbContrName.Value + ", " + tbContrAddr.Value + ", " + _
tbContrCSZ.Value + ", " + Format(tbContrPh.Value, "(000)000-0000")
tbContrPh.Value = Format(tbContrPh.Value, "(000)000-0000")
End Sub
Private Sub tbComp_Change()
cmbFinish.Enabled = True
End Sub
Private Sub cmbFinish_Click()
UpdateBookmark "AgreeDt", FormalDt ' <------Getting error here
UpdateBookmark "ContrInfo", ContrInfoCombo
UpdateBookmark "Services", tbServices.Value
UpdateBookmark "Comp", tbComp.Value
UpdateBookmark "Today", Format(Date, "MMM. d, yyyy")
SCD_EA_Window.Hide
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
varible information that I have bookmarked in the doc. I'll admit I'm a
novice at VBA so any help is appreciated.
I'm getting a "Compiler Error: ByRef argument type mismatch" error when I go
to run the UpdateBookmark sub (I got this from the MVP FAQ by Dave Rado).
The sub worked OK when I used the simple formated date value in a
"mm/dd/yyyy" format. But I need a ordinal day format "17th day of August
2009" which I produce in the calendar sub.
I'm using linked textboxes to flow the contractor info (reason for
concatenating), the services, and the compensation info in the doc. The
bookmarks are in the first textbox of each linked group.
I'm loading the doc with data when the "cmbFinish" button is clicked to give
the user the ability to review the info on the userform before the transfer.
Thx in advance. John G
-------------------------------
Public ContrInfoCombo, FormalDt, OrdinalDay As String
Private Sub cmbDate_Click()
With Calendar1
.Value = Date
.Visible = True
End With
Repaint
End Sub
Private Sub Calendar1_Click()
cmbDate.Visible = False
tbAgreeDt.Value = Format(Calendar1.Value, "mm/dd/yy")
Calendar1.Visible = False
lblLine.Visible = True
Select Case Day(tbAgreeDt.Value)
Case 1, 21, 31
OrdinalDay = Str(Day(tbAgreeDt.Value)) + "st"
Case 2, 22
OrdinalDay = Str(Day(tbAgreeDt.Value)) + "nd"
Case 3, 23
OrdinalDay = Str(Day(tbAgreeDt.Value)) + "rd"
Case Else
OrdinalDay = Str(Day(tbAgreeDt.Value)) + "th"
End Select
FormalDt = OrdinalDay + " day of " + Format(tbAgreeDt.Value, "MMMM yyyy")
End Sub
Private Sub tbContrPh_AfterUpdate()
ContrInfoCombo = tbContrName.Value + ", " + tbContrAddr.Value + ", " + _
tbContrCSZ.Value + ", " + Format(tbContrPh.Value, "(000)000-0000")
tbContrPh.Value = Format(tbContrPh.Value, "(000)000-0000")
End Sub
Private Sub tbComp_Change()
cmbFinish.Enabled = True
End Sub
Private Sub cmbFinish_Click()
UpdateBookmark "AgreeDt", FormalDt ' <------Getting error here
UpdateBookmark "ContrInfo", ContrInfoCombo
UpdateBookmark "Services", tbServices.Value
UpdateBookmark "Comp", tbComp.Value
UpdateBookmark "Today", Format(Date, "MMM. d, yyyy")
SCD_EA_Window.Hide
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