RE: Insert sentence only if text field is not null

Tech-Archive recommends: Fix windows errors by optimizing your registry



Sorry to be dense: but where does this go?

I've got

Private Sub btnCancel_Click()
Me.Hide
ActiveDocument.Close wdDoNotSaveChanges
End Sub

Private Sub btnOK_Click()
On Error Resume Next
Dim oRng As Word.Range

'Populating Guarantor bookmarks:

Set oRng = ActiveDocument.Bookmarks("bkGName").Range
oRng.Text = Me.txtGName
ActiveDocument.Bookmarks.Add Name:="bkGName", Range:=oRng
Selection.GoTo What:=wdGoToBookmark, Name:="bkGName"
(etcetera)

Me.Hide
ActiveDocument.PrintPreview
ActiveDocument.ClosePrintPreview
Selection.GoTo What:=wdGoToBookmark, Name:="bkStartHere"

End Sub

If I try to include it under the OK button, I get "expected end sub" error.

This is the code I modified from yours, so far no decompile or run errors;
but the bkBorrowerName does not populate in the document.

Private Sub InsertBKBorrower()
Dim myRange As Range
With ActiveDocument
If .Bookmarks.Exists("bkBorrowerName") Then
myRange = .Bookmarks("bkBorrowerName").Range
myRange.Text = fcnBuildBKBorrower
.Bookmarks.Add "BkBorrowerName", myRange
End If
End With
End Sub

Private Function fcnBuildBKBorrower() As String
Dim Temp As String
Temp = txtBorrower1.Value
If Len(txtBorrower2.Value) > 0 Then
Temp = Temp & " and " & txtBorrower2.Value & ", each, a 'Borrower'
and any reference to 'Borrower' singly or 'Borrowers' collectively means each
as well of them in their individual, and joint and several capacities."
End If
fcnBuildBKBorrower = Temp
End Function


.


Quantcast