Open a Form at the last page edited

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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 :-)
 
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 :-)
 
Back
Top