Simple Form Syntax Help Please

A

Angyl

I've tried this several ways and can't get it to work. I'm adding a macro to
a field and I want another field to change in the document based on what was
entered, but I'm having trouble referencing the field properly.

I've tried

If ActiveDocument.Text1.Text = "Hello" Then

and just

If Text1.Text = "Hello" Then

and

With ActiveDocument

If .FormFields.Text1.Text = "Hello" Then

and a couple others but I keep getting various errors. What's the proper
syntax for referencing a form field named Text 1 in a macro?
 
G

Greg Maxey

Something like this should get you on track:
Sub ScratchMacro()
With ActiveDocument
If .FormFields("Text1").Result = "Hello" Then
MsgBox "Bob's your uncle"
End If
End With
End Sub
 
A

Angyl

Many thanks, Greg.

Greg Maxey said:
Something like this should get you on track:
Sub ScratchMacro()
With ActiveDocument
If .FormFields("Text1").Result = "Hello" Then
MsgBox "Bob's your uncle"
End If
End With
End Sub
 

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