Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Checkbox to Unhide Text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JohnatSydney - 30 Aug 2006 05:42 GMT
Hi Folks - real beginner here with VBA in word, surrounded by technophobes!

Am trying to do a protected form letter. Users enter details in form fields
which populate through the letter using Cross references. There is one
paragraph that I need to insert/remove based on the user checking a checkbox.
(Checked = include the text, unchecked = exclude). My code is below, but I
get a 'Runtime Error 5941 - The requested member of the collection does not
exist.'

I know this is something simple I've done by not structuring the code
correctly...but can't seem to fix it.

Can anyone offer any advice?
- QualityCheck is the Formfield(Checkbox) Name
- QualityWords is the bookbark containing the hidden text.

If the document is password protected, so I need to unprotect to unhide the
text and re-protect again after it's run?

Sub UnhideQualityText()
Dim QualityCheck As String
   If FormFields(QualityCheck).CheckBox.Value = False Then
       ActiveDocument.Bookmarks("QualityWords").Range.Font.Hidden = True
   Else
       ActiveDocument.Bookmarks("QualityWords").Range.Font.Hidden = False
End If
End Sub

Appreciate any advice.....
Thanks,
John.
Jezebel - 30 Aug 2006 06:29 GMT
The mistake in your code is that you declare the string variable
QualityCheck but don't assign it a value. So the line
FormFields(QualityCheck) is effectively FormFields("")

Try --

ActiveDocument.Bookmarks("QualityWords").Range.Font.Hidden = not
FormFields("QualityCheck").CheckBox.Value

> Hi Folks - real beginner here with VBA in word, surrounded by
> technophobes!
[quoted text clipped - 32 lines]
> Thanks,
> John.
JohnatSydney - 30 Aug 2006 23:54 GMT
Thanks J - that's got it! Appreciate your expert advice.

Regards,
JOHN.

> The mistake in your code is that you declare the string variable
> QualityCheck but don't assign it a value. So the line
[quoted text clipped - 41 lines]
> > Thanks,
> > John.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.