Solved: Word 2003 - Simple automation - Guru help !

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

shaygate

Thread Starter
Joined
Mar 29, 2002
Messages
158
I have created a document for our engineers to use, as I am pretty much a VBA virgin I have been playing around with adding some simple automation and have run into a problem thats beyond my solving so I am asking you gurus out there !

In the document i have created a UserForm that starts as the document is opened (the document is in Print Layout View) , into some textboxes they type their Name, Date, and Project Name. on hitting the OK button the VBA goes to a series of bookmarks imbeded in the document using the commands

ActiveDocument.Bookmarks("name1").Select
Selection.InsertBefore Text:=TextBox2


and inserts the text from the user form, this is repeated for each catagory at different places in the document .... nice and simple.

However two of the date bookmarks are inside footers (two different sections) and when the routine is finished instead of returning home (ActiveDocument.Bookmarks("home").Select) to the start and remaining in Print Layout View the cursor remains in one of the footers and the document is in "Normal view"

Why is this happening and how can I stop or fix it ?, its obviously related to the bookmarks being inside a footer but why change the layout as well !! :confused:

Ian
 

shaygate

Thread Starter
Joined
Mar 29, 2002
Messages
158
Sorry its taken me a few days to respond, I was away for the Easter break.

Here is the code as requested though it will show the same as I explained in my original post.

Private Sub CommandButton1_Click()
ActiveDocument.Bookmarks("name1").Select
Selection.InsertBefore Text:=TextBox2
ActiveDocument.Bookmarks("name2").Select
Selection.InsertBefore Text:=TextBox2

ActiveDocument.Bookmarks("date1").Select
Selection.InsertBefore Text:=TextBox4
ActiveDocument.Bookmarks("date2").Select
Selection.InsertBefore Text:=TextBox4
ActiveDocument.Bookmarks("date3").Select
Selection.InsertBefore Text:=TextBox4
ActiveDocument.Bookmarks("date4").Select
Selection.InsertBefore Text:=TextBox4

ActiveDocument.Bookmarks("project1").Select
Selection.InsertBefore Text:=TextBox3

ActiveDocument.Bookmarks("home").Select

Unload UserForm1


End Sub


As you can see its all driven off the single command button, The bookmarks are set manualy in the base document and not by code.

Date3 & Date4 are the entries in the footers, (2 different sections) and bookmark Home is on Page 1 and is just used to return the cursor to the start of the document.
 
Joined
Sep 4, 2003
Messages
4,916
Try adding the lines below after inserting the last bit of text.

Selection.HomeKey Unit:=wdStory

ActiveDocument.ActiveWindow.View.Type = wdPrintView


Rollin
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top