Move cursor up several lines after form data entered in document
I have a Word template that is a letterhead. When the user opens a copy, a box comes up that asks them to fill out the files....Reference number, name and address of the recipient, subject, signature name and title....and enters all of the data in the letter at the appropriate bookmarks. This form works fine. However, what i would like to do is, after the last field is entered in the document, have the cursor jump up 7 lines to the main body of the letter....that is, between the Salutation and the signature lines. I had thought adding a subroutine like this would do it:
Public Sub MoveCursor()
'
' MoveCursor Macro
'
'
Selection.MoveUp Unit:=wdLine, Count:=7
End Sub
But either the routine is not correct, or I don't know how to properly call it after the form data is entered.
Here is the coding for the form data that works fine, and note, i tried adding a line to call the MoveCursor subroutine:
Private Sub cmdok_Click()
If txtoperator.Text = "" Then
MsgBox "You must enter in Our Reference Information!", vbInformation, "Enter Our Reference"
Exit Sub
End If
If txtsubject.Text = "" Then
MsgBox "You must enter in a Subject!", vbInformation, "Enter Subject"
Exit Sub
End If
If txtsalutation.Text = "" Then
MsgBox "You must enter something in the Salutation field!", vbInformation, "Enter Salutation"
Exit Sub
End If
If txtsname.Text = "" Then
MsgBox "You must enter the Sender's Name!", vbInformation, "Enter Sender's Name"
Exit Sub
End If
If txtstitle.Text = "" Then
MsgBox "You must enter the Sender's Title!", vbInformation, "Enter Sender's Title"
Exit Sub
End If
Unload letterform
Selection.Font.AllCaps = False
Selection.Font.Italic = True
Selection.Font.Bold = False
Selection.GoTo What:=wdGoToBookmark, Name:="yourref"
If Not txtYourRef = "" Then
Selection.TypeText "Your Reference: "
Selection.TypeText Text:=txtYourRef
End If
Selection.GoTo What:=wdGoToBookmark, Name:="ourref"
Selection.TypeText "Our Reference: "
Selection.TypeText Text:=txtoperator
Selection.Font.Bold = False
Selection.GoTo What:=wdGoToBookmark, Name:="DATE"
Selection.TypeText Format(Date, "dd mmm yyyy")
Selection.Paragraphs.TabStops.Add _
Position:=Application.CentimetersToPoints(2), _
Alignment:=wdAlignTabRight
Selection.GoTo What:=wdGoToBookmark, Name:="name"
Selection.TypeText Text:=txtname
Selection.GoTo What:=wdGoToBookmark, Name:="address"
Selection.TypeText Text:=txtaddress
Selection.GoTo What:=wdGoToBookmark, Name:="addr2"
Selection.Font.AllCaps = True
Selection.TypeText Text:=txtaddr2
Selection.TypeParagraph
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
Selection.TypeParagraph
Selection.TypeParagraph
Selection.Font.AllCaps = False
Selection.TypeText "Dear "
Selection.TypeText Text:=txtsalutation
Selection.TypeText ","
Selection.TypeParagraph
Selection.TypeParagraph
If Not txtsubject = "" Then
Selection.Font.Bold = True
Selection.TypeText "Re: "
Selection.TypeText Text:=txtsubject
Selection.Font.Bold = False
Selection.GoTo What:=wdGoToBookmark, Name:="sname"
Selection.TypeText Text:=txtsname
Selection.Font.Bold = True
Selection.GoTo What:=wdGoToBookmark, Name:="stitle"
Selection.TypeText Text:=txtstitle
Selection.MoveUp Unit:=wdParagraph, Count:=8, Extend:=wdExtend
Call MoveCursor
End If
End With
Selection.EndKey Unit:=wdStory
End Sub
Am I asking the impossible, or can this be done?
|