Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to return a value from a Bookmark and assign to variable...

Status
Not open for further replies.

Sdeen

Technical User
Jan 12, 2005
1
US
Greetings,

We are using Office 97 and Office 2003 at work...

The macro I wrote in 2003 works, but when I took it back to 97 it didn't, it seems to have the problem in the section with the bookmark.

The macro returns a value from a bookmark called VisitorName. The Bookmark is the property of a field in a protected form.

A button on the word form runs the macro to call outlook and create a message attaching the word form and filling in the subject, the problem is... my user wants the visitors name from the form to be in the subject line too.

That is the form field named VisitorName.

Here is my section of code...

If ActiveDocument.Bookmarks.Exists("VisitorName") = True Then
ActiveDocument.Bookmarks("VisitorName").Select
vName = Selection.Text
End If

The next part adds the VName variable to the outlook subject line.

This code works in 2003 but not 97. The variable is empty in 97..

I am going crazy...

Can you help?

Thanks
Sdeen
 
Sdeen,

Here's the code I use to populate a variable with the data found at a bookmark.

Dim Qscale0 As String
Dim Qscale1 As String


' Field definition
' Each question or statement has 32 possible ratings. There are 4 importances and 8 scale rating.
' The field names are defined as such.
' Q1Im0_0 or Q1Im1_0 are example names and consist of three parts.
' Q1 -> question or statement number. Q1, Q2, Q3 etc.
' Im0 -> Importance rating. Im0 = no importance, Im3 = high importance
' _0 -> scale rating. 0 = Not applicable, 2 = disagree, 3 = agree


' Question #1 - No Importance
WordBasic.WW7_EditGoTo "Q1Im0_0"
Qscale0 = WordBasic.Val(WordBasic.[GetFormResult$]("Q1Im0_0"))
WordBasic.WW7_EditGoTo "Q1Im0_1"
Qscale1 = WordBasic.Val(WordBasic.[GetFormResult$]("Q1Im0_1"))

Maybe this will help.
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top