|
-
Mar 26th, 2003, 10:14 AM
#1
Thread Starter
Addicted Member
Word: Setting Form Field Bookmarks
I have two macros. One does what I need it to. The other doesn't. There is a single line of code difference, and I can't figure out why that line is causing a problem.
I need to build a Word form where I can set the bookmark field of each form field.
Code:
Sub Bad()
Documents.Add.Activate
ActiveDocument.Paragraphs.Add
Selection.Tables.Add Selection.Range, 2, 2
Selection.Tables.Item(1).Cell(1, 1).Range.InsertAfter "Text"
Selection.Tables.Item(1).Cell(1, 2).Select
Selection.FormFields.Add Selection.Range, wdFieldFormTextInput
ActiveDocument.FormFields.Item(1).Name = "fldName"
ActiveDocument.FormFields.Item("fldName").Result = "Result"
ActiveDocument.Protect wdAllowOnlyFormFields, True
ActiveDocument.SaveAs "C:\THG\Bad.doc"
ActiveDocument.Close
End Sub
Sub Good()
Documents.Add.Activate
ActiveDocument.Paragraphs.Add
Selection.Tables.Add Selection.Range, 2, 2
Selection.Tables.Item(1).Cell(1, 2).Select
Selection.FormFields.Add Selection.Range, wdFieldFormTextInput
ActiveDocument.FormFields.Item(1).Name = "fldName"
ActiveDocument.FormFields.Item("fldName").Result = "Result"
ActiveDocument.Protect wdAllowOnlyFormFields, True
ActiveDocument.SaveAs "C:\THG\Good.doc"
ActiveDocument.Close
End Sub
I hope this makes sense.
Travis, Kung Foo Journeyman
Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
OSS: Mozilla, MySQL (Manual)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|