Open a Form at the last page edited

  • Thread starter User of the Word
  • Start date
U

User of the Word

I created and use a MS word form at work. I want it to open at the last page
edited. The form has to be protected so the neither "Shift+F5" shortcut or
the "Goback" macro work.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?VXNlciBvZiB0aGUgV29yZA==?=,
I created and use a MS word form at work. I want it to open at the last page
edited. The form has to be protected so the neither "Shift+F5" shortcut or
the "Goback" macro work.
You could include a pair of macros in the form named AutoClose and AutoOpen. The
first would note the name of the current form field when the document is closed
in a document variable (or property). The second would check this value when the
document is opened and move to that field. Example:

Sub AutoClose()
If Selection.Bookmarks.count > 0 Then
ActiveDocument.Variables("LastField").Value _
= Selection.Bookmarks(1).Name
Else
ActiveDocument.Variables("LastField").Value _
= "invalid"
End If
End Sub

Sub AutoOpen()
Dim sLastField as String

sLastField = ActiveDocument.Variables("LastField")
If sLastField <> "invalid" Then
ActiveDocument.Formfields(sLastField).Select
End If
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
U

User of the Word

Sorry Cindy, it didn't work.

Cindy M -WordMVP- said:
Hi =?Utf-8?B?VXNlciBvZiB0aGUgV29yZA==?=,

You could include a pair of macros in the form named AutoClose and AutoOpen. The
first would note the name of the current form field when the document is closed
in a document variable (or property). The second would check this value when the
document is opened and move to that field. Example:

Sub AutoClose()
If Selection.Bookmarks.count > 0 Then
ActiveDocument.Variables("LastField").Value _
= Selection.Bookmarks(1).Name
Else
ActiveDocument.Variables("LastField").Value _
= "invalid"
End If
End Sub

Sub AutoOpen()
Dim sLastField as String

sLastField = ActiveDocument.Variables("LastField")
If sLastField <> "invalid" Then
ActiveDocument.Formfields(sLastField).Select
End If
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)


This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top