Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-22-2018, 09:33 PM
zanestein zanestein is offline Move cursor up several lines after form data entered in document Windows 7 32bit Move cursor up several lines after form data entered in document Office 2010 32bit
Novice
Move cursor up several lines after form data entered in document
 
Join Date: May 2018
Posts: 4
zanestein is on a distinguished road
Default 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?
Reply With Quote
 

Tags
form, moveup



Similar Threads
Thread Thread Starter Forum Replies Last Post
Move cursor up several lines after form data entered in document A macro to find a symbol, delete it, and move the cursor to that location JayBird24 Word VBA 1 08-19-2016 04:26 PM
Move cursor up several lines after form data entered in document move cursor anand Word VBA 14 07-07-2015 05:57 AM
How do I move the cursor back to the text from a comment without using the mouse? MsT Word 2 04-24-2014 05:48 PM
Cursor skips to previous lines KimM Office 1 01-09-2010 08:13 AM
can't move the cursor in Word pieboy Word 2 02-13-2009 07:15 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:39 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft