|
|
|
date: Tue, 19 Aug 2008 08:26:07 -0700,
group: microsoft.public.word.vba.general
back
Re: Bookmarks - Requested member of collection does not exist
Thank you soooo very much for your quick reply. I am VEEEEEERY new to this so
I beg your forgiveness in advance. I did add the command suggested (right
after my "range.delete" command). It works in that the "requested member ...
does not exist" message does not pop up anymore, which is very good.
However, if I go back to the DD, the DD field disappears, which is not so
good (which, I assume, is because I am re-adding the empty bookmark in the
field where the macro that erase the bookmark in the first place is linked).
Am I making any sense? Could I re-add the bookmark somewhere else where it
would not erase the DD field if I go back to this field?
And, let me push my luck a little... Ideally, in an ideal world, what would
be the top and would make my day (and even my week -- my year even!!!), would
be to have this very complex text (ie with DD, fields, cross-referencing,
paragraph numbering) in this enclosing bookmark "disappear" when the user
selects "No" in the DD and then "reappear" should the user go back to the DD
field, changes his mind and selects "yes" instead of "no"
Any help you could provide (or reading material) would be so very much
appreciated.
"Jay Freedman" wrote:
> ItsMe wrote:
> > In a protected form, I created a macro in exiting a DD field so the
> > content of an enclosing bookmark somewhere else in the document
> > disappears when the user chooses "No".
> > If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > pToggleProtectDoc (ie to unprotect doc)
> > ActiveDocument.Bookmarks("bkxxxxx").Range.Delete
> > pToggleProtectDoc (ie to reprotect doc)
> > Else
> > Exit Sub
> > End If
> > Everything works perfectly fine except that if I somehow go back to
> > the DD field, of course this message pops up: "requested member of
> > collection does not exist".
> >
> > Is there a line that I could add to my macro to prevent this.
> >
> > Thanks in advance.
>
> If there's any possibility that this code can be executed more than once,
> then you have to re-insert the empty bookmark after removing its text
> content. See
> http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm for the
> technique.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> all may benefit.
>
>
>
date: Tue, 19 Aug 2008 12:56:09 -0700
author: ItsMe
Re: Bookmarks - Requested member of collection does not exist
There is a simple - altho possible not ideal - solution to making the text in
the bookmark "disappear" and "reappear". Rewrite your sub as follows:
pToggleProtectDoc (ie to unprotect doc)
If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = True
Else
ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = False
End If
pToggleProtectDoc (ie to reprotect doc)
This will simply hide the text in the bookmark. However, depending on the
version of Word and the user's display settings, the text may still be
visible on the screen - although it will be marked as hidden. It may also
print if the user sets the option to print hidden text.
There are better but more complex solutions possible, but I think this
should suite your needs for the moment.
You can also add some error handling to prevent that really ugly VBA error
from being displayed. Check out the VBA help on the .Exists method of the
Bookmark object. This method can be used as follows:
If ActiveDocument.Bookmarks("bkxxxxx").Exists = True Then
pToggleProtectDoc (ie to unprotect doc)
If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = True
Else
ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = False
End If
pToggleProtectDoc (ie to reprotect doc)
Else
MsgBox "The Bookmark " & ActiveDocument.Bookmarks("bkxxxxx").Name & "
cannot be found." & vbCr & "Contact ItsMe for assistance.", vbCritical,
"Bookmark Error"
End If
And one final note on your code. Not every If statement requires an Else
statement. Accordingly, your code
Else
Exit Sub
could be removed without effect. In this instance especially, unless you
have something else in the procedure that you do not wish to be executed if
the FormField's Result is "Yes" (or at least not "No"), there is no need to
explicitly exit the procedure; the code will simply run to the End Sub
statement and exit of its own accord.
--
Cheers!
Gordon
Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
"ItsMe" wrote:
> Thank you soooo very much for your quick reply. I am VEEEEEERY new to this so
> I beg your forgiveness in advance. I did add the command suggested (right
> after my "range.delete" command). It works in that the "requested member ...
> does not exist" message does not pop up anymore, which is very good.
>
> However, if I go back to the DD, the DD field disappears, which is not so
> good (which, I assume, is because I am re-adding the empty bookmark in the
> field where the macro that erase the bookmark in the first place is linked).
> Am I making any sense? Could I re-add the bookmark somewhere else where it
> would not erase the DD field if I go back to this field?
>
> And, let me push my luck a little... Ideally, in an ideal world, what would
> be the top and would make my day (and even my week -- my year even!!!), would
> be to have this very complex text (ie with DD, fields, cross-referencing,
> paragraph numbering) in this enclosing bookmark "disappear" when the user
> selects "No" in the DD and then "reappear" should the user go back to the DD
> field, changes his mind and selects "yes" instead of "no"
>
> Any help you could provide (or reading material) would be so very much
> appreciated.
>
> "Jay Freedman" wrote:
>
> > ItsMe wrote:
> > > In a protected form, I created a macro in exiting a DD field so the
> > > content of an enclosing bookmark somewhere else in the document
> > > disappears when the user chooses "No".
> > > If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > > pToggleProtectDoc (ie to unprotect doc)
> > > ActiveDocument.Bookmarks("bkxxxxx").Range.Delete
> > > pToggleProtectDoc (ie to reprotect doc)
> > > Else
> > > Exit Sub
> > > End If
> > > Everything works perfectly fine except that if I somehow go back to
> > > the DD field, of course this message pops up: "requested member of
> > > collection does not exist".
> > >
> > > Is there a line that I could add to my macro to prevent this.
> > >
> > > Thanks in advance.
> >
> > If there's any possibility that this code can be executed more than once,
> > then you have to re-insert the empty bookmark after removing its text
> > content. See
> > http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm for the
> > technique.
> >
> > --
> > Regards,
> > Jay Freedman
> > Microsoft Word MVP FAQ: http://word.mvps.org
> > Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> > all may benefit.
> >
> >
> >
date: Tue, 19 Aug 2008 14:51:02 -0700
author: Gordon Bentley-Mix gordon(dot)bentleymix(at)gmail(dot)com
Re: Bookmarks - Requested member of collection does not exist
I am totally jealous Gordon -- wish I were as proficient and had more time to
explore all that. I had thought of something along the lines of "hidden" but
too many users, too many settings and at least 3 different versions of Word
(2000-02 & 03) and it is imperative that the hidden text does not show on
printing.
I used this .Exists("bkxxx") line and it solved the message problem. Thanks
a million for your pointers. It is complex indeed b/c, of course, when I go
back to the DD field and re-choose "yes", text does not reappear. I will
explore a temporary solution (if it exists???) whereby I will deactivate the
field once the user has selected his answer.
Needless to say that if you ever find yourself with nothing to do (hihi) and
way too much time on your hands (hihi) and wish to help me with this complex
disappearing act, I would be forever grateful. Boy, do I wish we were in the
same office !!!
Carmen
"Gordon Bentley-Mix" wrote:
> There is a simple - altho possible not ideal - solution to making the text in
> the bookmark "disappear" and "reappear". Rewrite your sub as follows:
>
> pToggleProtectDoc (ie to unprotect doc)
> If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = True
> Else
> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = False
> End If
> pToggleProtectDoc (ie to reprotect doc)
>
> This will simply hide the text in the bookmark. However, depending on the
> version of Word and the user's display settings, the text may still be
> visible on the screen - although it will be marked as hidden. It may also
> print if the user sets the option to print hidden text.
>
> There are better but more complex solutions possible, but I think this
> should suite your needs for the moment.
>
> You can also add some error handling to prevent that really ugly VBA error
> from being displayed. Check out the VBA help on the .Exists method of the
> Bookmark object. This method can be used as follows:
>
> If ActiveDocument.Bookmarks("bkxxxxx").Exists = True Then
> pToggleProtectDoc (ie to unprotect doc)
> If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = True
> Else
> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = False
> End If
> pToggleProtectDoc (ie to reprotect doc)
> Else
> MsgBox "The Bookmark " & ActiveDocument.Bookmarks("bkxxxxx").Name & "
> cannot be found." & vbCr & "Contact ItsMe for assistance.", vbCritical,
> "Bookmark Error"
> End If
>
> And one final note on your code. Not every If statement requires an Else
> statement. Accordingly, your code
>
> Else
> Exit Sub
>
> could be removed without effect. In this instance especially, unless you
> have something else in the procedure that you do not wish to be executed if
> the FormField's Result is "Yes" (or at least not "No"), there is no need to
> explicitly exit the procedure; the code will simply run to the End Sub
> statement and exit of its own accord.
> --
> Cheers!
> Gordon
>
> Uninvited email contact will be marked as SPAM and ignored. Please post all
> follow-ups to the newsgroup.
>
>
> "ItsMe" wrote:
>
> > Thank you soooo very much for your quick reply. I am VEEEEEERY new to this so
> > I beg your forgiveness in advance. I did add the command suggested (right
> > after my "range.delete" command). It works in that the "requested member ...
> > does not exist" message does not pop up anymore, which is very good.
> >
> > However, if I go back to the DD, the DD field disappears, which is not so
> > good (which, I assume, is because I am re-adding the empty bookmark in the
> > field where the macro that erase the bookmark in the first place is linked).
> > Am I making any sense? Could I re-add the bookmark somewhere else where it
> > would not erase the DD field if I go back to this field?
> >
> > And, let me push my luck a little... Ideally, in an ideal world, what would
> > be the top and would make my day (and even my week -- my year even!!!), would
> > be to have this very complex text (ie with DD, fields, cross-referencing,
> > paragraph numbering) in this enclosing bookmark "disappear" when the user
> > selects "No" in the DD and then "reappear" should the user go back to the DD
> > field, changes his mind and selects "yes" instead of "no"
> >
> > Any help you could provide (or reading material) would be so very much
> > appreciated.
> >
> > "Jay Freedman" wrote:
> >
> > > ItsMe wrote:
> > > > In a protected form, I created a macro in exiting a DD field so the
> > > > content of an enclosing bookmark somewhere else in the document
> > > > disappears when the user chooses "No".
> > > > If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > > > pToggleProtectDoc (ie to unprotect doc)
> > > > ActiveDocument.Bookmarks("bkxxxxx").Range.Delete
> > > > pToggleProtectDoc (ie to reprotect doc)
> > > > Else
> > > > Exit Sub
> > > > End If
> > > > Everything works perfectly fine except that if I somehow go back to
> > > > the DD field, of course this message pops up: "requested member of
> > > > collection does not exist".
> > > >
> > > > Is there a line that I could add to my macro to prevent this.
> > > >
> > > > Thanks in advance.
> > >
> > > If there's any possibility that this code can be executed more than once,
> > > then you have to re-insert the empty bookmark after removing its text
> > > content. See
> > > http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm for the
> > > technique.
> > >
> > > --
> > > Regards,
> > > Jay Freedman
> > > Microsoft Word MVP FAQ: http://word.mvps.org
> > > Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> > > all may benefit.
> > >
> > >
> > >
date: Wed, 20 Aug 2008 06:38:26 -0700
author: ItsMe
Re: Bookmarks - Requested member of collection does not exist
Carmen,
I'm afraid you'd have to move to New Zealand to share an office. ;-p
You could still use the "hidden" text option if you're willing to jump
through a few hoops. You could always fiddle with the "View" settings to make
sure that hidden text isn't displayed after the document is built - but this
is something that I don't generally like to do as users tend to get a bit
cross if settings start changing without them knowing why. That said, most
users aren't any the wiser if hidden text is... well... hidden, so maybe you
could get away with this. Those that do want to see hidden text usually know
how to go about displaying it again. (A couple of tips on this approach: look
at the View property of the ActiveWindow object and be aware that ShowAll
will have an role to play as well.)
As for printing, you could write FilePrint and FilePrintDefault procedures
into the template that would ensure that hidden text isn't printed. If you
search on "FilePrintDefault" you'll find a recent post called "VBA to change
Display for Review setting" in which Jay Freedman discusses writing these
procedures. From there it's just a matter of poking around in the VBA help
until you find the setting for making sure hidden text isn't printed. The
nice thing about this approach is that it should be document-specific, so it
shouldn't have an impact on the printing of any other document.
(Just quietly, I think you could probably get away with this approach
without too much complaint from anyone; hiding and not printing hidden text
is actually the default, so if you just enforced it with code...)
--
Cheers!
Gordon
Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
"ItsMe" wrote:
> I am totally jealous Gordon -- wish I were as proficient and had more time to
> explore all that. I had thought of something along the lines of "hidden" but
> too many users, too many settings and at least 3 different versions of Word
> (2000-02 & 03) and it is imperative that the hidden text does not show on
> printing.
>
> I used this .Exists("bkxxx") line and it solved the message problem. Thanks
> a million for your pointers. It is complex indeed b/c, of course, when I go
> back to the DD field and re-choose "yes", text does not reappear. I will
> explore a temporary solution (if it exists???) whereby I will deactivate the
> field once the user has selected his answer.
>
> Needless to say that if you ever find yourself with nothing to do (hihi) and
> way too much time on your hands (hihi) and wish to help me with this complex
> disappearing act, I would be forever grateful. Boy, do I wish we were in the
> same office !!!
> Carmen
>
> "Gordon Bentley-Mix" wrote:
>
> > There is a simple - altho possible not ideal - solution to making the text in
> > the bookmark "disappear" and "reappear". Rewrite your sub as follows:
> >
> > pToggleProtectDoc (ie to unprotect doc)
> > If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = True
> > Else
> > ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = False
> > End If
> > pToggleProtectDoc (ie to reprotect doc)
> >
> > This will simply hide the text in the bookmark. However, depending on the
> > version of Word and the user's display settings, the text may still be
> > visible on the screen - although it will be marked as hidden. It may also
> > print if the user sets the option to print hidden text.
> >
> > There are better but more complex solutions possible, but I think this
> > should suite your needs for the moment.
> >
> > You can also add some error handling to prevent that really ugly VBA error
> > from being displayed. Check out the VBA help on the .Exists method of the
> > Bookmark object. This method can be used as follows:
> >
> > If ActiveDocument.Bookmarks("bkxxxxx").Exists = True Then
> > pToggleProtectDoc (ie to unprotect doc)
> > If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = True
> > Else
> > ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = False
> > End If
> > pToggleProtectDoc (ie to reprotect doc)
> > Else
> > MsgBox "The Bookmark " & ActiveDocument.Bookmarks("bkxxxxx").Name & "
> > cannot be found." & vbCr & "Contact ItsMe for assistance.", vbCritical,
> > "Bookmark Error"
> > End If
> >
> > And one final note on your code. Not every If statement requires an Else
> > statement. Accordingly, your code
> >
> > Else
> > Exit Sub
> >
> > could be removed without effect. In this instance especially, unless you
> > have something else in the procedure that you do not wish to be executed if
> > the FormField's Result is "Yes" (or at least not "No"), there is no need to
> > explicitly exit the procedure; the code will simply run to the End Sub
> > statement and exit of its own accord.
> > --
> > Cheers!
> > Gordon
> >
> > Uninvited email contact will be marked as SPAM and ignored. Please post all
> > follow-ups to the newsgroup.
> >
> >
> > "ItsMe" wrote:
> >
> > > Thank you soooo very much for your quick reply. I am VEEEEEERY new to this so
> > > I beg your forgiveness in advance. I did add the command suggested (right
> > > after my "range.delete" command). It works in that the "requested member ...
> > > does not exist" message does not pop up anymore, which is very good.
> > >
> > > However, if I go back to the DD, the DD field disappears, which is not so
> > > good (which, I assume, is because I am re-adding the empty bookmark in the
> > > field where the macro that erase the bookmark in the first place is linked).
> > > Am I making any sense? Could I re-add the bookmark somewhere else where it
> > > would not erase the DD field if I go back to this field?
> > >
> > > And, let me push my luck a little... Ideally, in an ideal world, what would
> > > be the top and would make my day (and even my week -- my year even!!!), would
> > > be to have this very complex text (ie with DD, fields, cross-referencing,
> > > paragraph numbering) in this enclosing bookmark "disappear" when the user
> > > selects "No" in the DD and then "reappear" should the user go back to the DD
> > > field, changes his mind and selects "yes" instead of "no"
> > >
> > > Any help you could provide (or reading material) would be so very much
> > > appreciated.
> > >
> > > "Jay Freedman" wrote:
> > >
> > > > ItsMe wrote:
> > > > > In a protected form, I created a macro in exiting a DD field so the
> > > > > content of an enclosing bookmark somewhere else in the document
> > > > > disappears when the user chooses "No".
> > > > > If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > > > > pToggleProtectDoc (ie to unprotect doc)
> > > > > ActiveDocument.Bookmarks("bkxxxxx").Range.Delete
> > > > > pToggleProtectDoc (ie to reprotect doc)
> > > > > Else
> > > > > Exit Sub
> > > > > End If
> > > > > Everything works perfectly fine except that if I somehow go back to
> > > > > the DD field, of course this message pops up: "requested member of
> > > > > collection does not exist".
> > > > >
> > > > > Is there a line that I could add to my macro to prevent this.
> > > > >
> > > > > Thanks in advance.
> > > >
> > > > If there's any possibility that this code can be executed more than once,
> > > > then you have to re-insert the empty bookmark after removing its text
> > > > content. See
> > > > http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm for the
> > > > technique.
> > > >
> > > > --
> > > > Regards,
> > > > Jay Freedman
> > > > Microsoft Word MVP FAQ: http://word.mvps.org
> > > > Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> > > > all may benefit.
> > > >
> > > >
> > > >
date: Wed, 20 Aug 2008 19:31:01 -0700
author: Gordon Bentley-Mix gordon(dot)bentleymix(at)gmail(dot)com
Re: Bookmarks - Requested member of collection does not exist
Hi Gordon,
You are driving me crazy. This just goes to show how little I know.
NewZealand... very exotic I'd imagine but quite far from my Montreal Québec
where we are having the worst summer ever by the way. So far yet so close. I
will look at all that over the w-end and try a few things, hopefully with
some success (if the "luck of the beginner" kicks in). Hidden text shouldn't
be a problem since none of them really knows Word at all.
You are all (mostly same group of people seem to reply to these desperate
posts) very vey nice and exceptionally giving of your time. Thank you and
thank God you are there...
"Gordon Bentley-Mix" wrote:
> Carmen,
>
> I'm afraid you'd have to move to New Zealand to share an office. ;-p
>
> You could still use the "hidden" text option if you're willing to jump
> through a few hoops. You could always fiddle with the "View" settings to make
> sure that hidden text isn't displayed after the document is built - but this
> is something that I don't generally like to do as users tend to get a bit
> cross if settings start changing without them knowing why. That said, most
> users aren't any the wiser if hidden text is... well... hidden, so maybe you
> could get away with this. Those that do want to see hidden text usually know
> how to go about displaying it again. (A couple of tips on this approach: look
> at the View property of the ActiveWindow object and be aware that ShowAll
> will have an role to play as well.)
>
> As for printing, you could write FilePrint and FilePrintDefault procedures
> into the template that would ensure that hidden text isn't printed. If you
> search on "FilePrintDefault" you'll find a recent post called "VBA to change
> Display for Review setting" in which Jay Freedman discusses writing these
> procedures. From there it's just a matter of poking around in the VBA help
> until you find the setting for making sure hidden text isn't printed. The
> nice thing about this approach is that it should be document-specific, so it
> shouldn't have an impact on the printing of any other document.
>
> (Just quietly, I think you could probably get away with this approach
> without too much complaint from anyone; hiding and not printing hidden text
> is actually the default, so if you just enforced it with code...)
> --
> Cheers!
> Gordon
>
> Uninvited email contact will be marked as SPAM and ignored. Please post all
> follow-ups to the newsgroup.
>
>
> "ItsMe" wrote:
>
> > I am totally jealous Gordon -- wish I were as proficient and had more time to
> > explore all that. I had thought of something along the lines of "hidden" but
> > too many users, too many settings and at least 3 different versions of Word
> > (2000-02 & 03) and it is imperative that the hidden text does not show on
> > printing.
> >
> > I used this .Exists("bkxxx") line and it solved the message problem. Thanks
> > a million for your pointers. It is complex indeed b/c, of course, when I go
> > back to the DD field and re-choose "yes", text does not reappear. I will
> > explore a temporary solution (if it exists???) whereby I will deactivate the
> > field once the user has selected his answer.
> >
> > Needless to say that if you ever find yourself with nothing to do (hihi) and
> > way too much time on your hands (hihi) and wish to help me with this complex
> > disappearing act, I would be forever grateful. Boy, do I wish we were in the
> > same office !!!
> > Carmen
> >
> > "Gordon Bentley-Mix" wrote:
> >
> > > There is a simple - altho possible not ideal - solution to making the text in
> > > the bookmark "disappear" and "reappear". Rewrite your sub as follows:
> > >
> > > pToggleProtectDoc (ie to unprotect doc)
> > > If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > > ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = True
> > > Else
> > > ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = False
> > > End If
> > > pToggleProtectDoc (ie to reprotect doc)
> > >
> > > This will simply hide the text in the bookmark. However, depending on the
> > > version of Word and the user's display settings, the text may still be
> > > visible on the screen - although it will be marked as hidden. It may also
> > > print if the user sets the option to print hidden text.
> > >
> > > There are better but more complex solutions possible, but I think this
> > > should suite your needs for the moment.
> > >
> > > You can also add some error handling to prevent that really ugly VBA error
> > > from being displayed. Check out the VBA help on the .Exists method of the
> > > Bookmark object. This method can be used as follows:
> > >
> > > If ActiveDocument.Bookmarks("bkxxxxx").Exists = True Then
> > > pToggleProtectDoc (ie to unprotect doc)
> > > If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > > ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = True
> > > Else
> > > ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden = False
> > > End If
> > > pToggleProtectDoc (ie to reprotect doc)
> > > Else
> > > MsgBox "The Bookmark " & ActiveDocument.Bookmarks("bkxxxxx").Name & "
> > > cannot be found." & vbCr & "Contact ItsMe for assistance.", vbCritical,
> > > "Bookmark Error"
> > > End If
> > >
> > > And one final note on your code. Not every If statement requires an Else
> > > statement. Accordingly, your code
> > >
> > > Else
> > > Exit Sub
> > >
> > > could be removed without effect. In this instance especially, unless you
> > > have something else in the procedure that you do not wish to be executed if
> > > the FormField's Result is "Yes" (or at least not "No"), there is no need to
> > > explicitly exit the procedure; the code will simply run to the End Sub
> > > statement and exit of its own accord.
> > > --
> > > Cheers!
> > > Gordon
> > >
> > > Uninvited email contact will be marked as SPAM and ignored. Please post all
> > > follow-ups to the newsgroup.
> > >
> > >
> > > "ItsMe" wrote:
> > >
> > > > Thank you soooo very much for your quick reply. I am VEEEEEERY new to this so
> > > > I beg your forgiveness in advance. I did add the command suggested (right
> > > > after my "range.delete" command). It works in that the "requested member ...
> > > > does not exist" message does not pop up anymore, which is very good.
> > > >
> > > > However, if I go back to the DD, the DD field disappears, which is not so
> > > > good (which, I assume, is because I am re-adding the empty bookmark in the
> > > > field where the macro that erase the bookmark in the first place is linked).
> > > > Am I making any sense? Could I re-add the bookmark somewhere else where it
> > > > would not erase the DD field if I go back to this field?
> > > >
> > > > And, let me push my luck a little... Ideally, in an ideal world, what would
> > > > be the top and would make my day (and even my week -- my year even!!!), would
> > > > be to have this very complex text (ie with DD, fields, cross-referencing,
> > > > paragraph numbering) in this enclosing bookmark "disappear" when the user
> > > > selects "No" in the DD and then "reappear" should the user go back to the DD
> > > > field, changes his mind and selects "yes" instead of "no"
> > > >
> > > > Any help you could provide (or reading material) would be so very much
> > > > appreciated.
> > > >
> > > > "Jay Freedman" wrote:
> > > >
> > > > > ItsMe wrote:
> > > > > > In a protected form, I created a macro in exiting a DD field so the
> > > > > > content of an enclosing bookmark somewhere else in the document
> > > > > > disappears when the user chooses "No".
> > > > > > If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > > > > > pToggleProtectDoc (ie to unprotect doc)
> > > > > > ActiveDocument.Bookmarks("bkxxxxx").Range.Delete
> > > > > > pToggleProtectDoc (ie to reprotect doc)
> > > > > > Else
> > > > > > Exit Sub
> > > > > > End If
> > > > > > Everything works perfectly fine except that if I somehow go back to
> > > > > > the DD field, of course this message pops up: "requested member of
> > > > > > collection does not exist".
> > > > > >
> > > > > > Is there a line that I could add to my macro to prevent this.
> > > > > >
> > > > > > Thanks in advance.
> > > > >
> > > > > If there's any possibility that this code can be executed more than once,
> > > > > then you have to re-insert the empty bookmark after removing its text
> > > > > content. See
> > > > > http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm for the
> > > > > technique.
> > > > >
> > > > > --
> > > > > Regards,
> > > > > Jay Freedman
> > > > > Microsoft Word MVP FAQ: http://word.mvps.org
> > > > > Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> > > > > all may benefit.
> > > > >
> > > > >
> > > > >
date: Thu, 21 Aug 2008 06:47:01 -0700
author: ItsMe
Re: Bookmarks - Requested member of collection does not exist
Gordon/Carmen
You both might have a look at:
http://gregmaxey.mvps.org/Toggle_Data_Display.htm. I think you could adapt
it to toggle with the results of a formfield.
ItsMe wrote:
> Hi Gordon,
> You are driving me crazy. This just goes to show how little I know.
> NewZealand... very exotic I'd imagine but quite far from my Montreal
> Québec where we are having the worst summer ever by the way. So far
> yet so close. I will look at all that over the w-end and try a few
> things, hopefully with some success (if the "luck of the beginner"
> kicks in). Hidden text shouldn't be a problem since none of them
> really knows Word at all.
>
> You are all (mostly same group of people seem to reply to these
> desperate posts) very vey nice and exceptionally giving of your time.
> Thank you and thank God you are there...
>
> "Gordon Bentley-Mix" wrote:
>
>> Carmen,
>>
>> I'm afraid you'd have to move to New Zealand to share an office. ;-p
>>
>> You could still use the "hidden" text option if you're willing to
>> jump through a few hoops. You could always fiddle with the "View"
>> settings to make sure that hidden text isn't displayed after the
>> document is built - but this is something that I don't generally
>> like to do as users tend to get a bit cross if settings start
>> changing without them knowing why. That said, most users aren't any
>> the wiser if hidden text is... well... hidden, so maybe you could
>> get away with this. Those that do want to see hidden text usually
>> know how to go about displaying it again. (A couple of tips on this
>> approach: look at the View property of the ActiveWindow object and
>> be aware that ShowAll will have an role to play as well.)
>>
>> As for printing, you could write FilePrint and FilePrintDefault
>> procedures into the template that would ensure that hidden text
>> isn't printed. If you search on "FilePrintDefault" you'll find a
>> recent post called "VBA to change Display for Review setting" in
>> which Jay Freedman discusses writing these procedures. From there
>> it's just a matter of poking around in the VBA help until you find
>> the setting for making sure hidden text isn't printed. The nice
>> thing about this approach is that it should be document-specific, so
>> it shouldn't have an impact on the printing of any other document.
>>
>> (Just quietly, I think you could probably get away with this approach
>> without too much complaint from anyone; hiding and not printing
>> hidden text is actually the default, so if you just enforced it with
>> code...) --
>> Cheers!
>> Gordon
>>
>> Uninvited email contact will be marked as SPAM and ignored. Please
>> post all follow-ups to the newsgroup.
>>
>>
>> "ItsMe" wrote:
>>
>>> I am totally jealous Gordon -- wish I were as proficient and had
>>> more time to explore all that. I had thought of something along the
>>> lines of "hidden" but too many users, too many settings and at
>>> least 3 different versions of Word (2000-02 & 03) and it is
>>> imperative that the hidden text does not show on printing.
>>>
>>> I used this .Exists("bkxxx") line and it solved the message
>>> problem. Thanks a million for your pointers. It is complex indeed
>>> b/c, of course, when I go back to the DD field and re-choose "yes",
>>> text does not reappear. I will explore a temporary solution (if it
>>> exists???) whereby I will deactivate the field once the user has
>>> selected his answer.
>>>
>>> Needless to say that if you ever find yourself with nothing to do
>>> (hihi) and way too much time on your hands (hihi) and wish to help
>>> me with this complex disappearing act, I would be forever grateful.
>>> Boy, do I wish we were in the same office !!!
>>> Carmen
>>>
>>> "Gordon Bentley-Mix" wrote:
>>>
>>>> There is a simple - altho possible not ideal - solution to making
>>>> the text in the bookmark "disappear" and "reappear". Rewrite your
>>>> sub as follows:
>>>>
>>>> pToggleProtectDoc (ie to unprotect doc)
>>>> If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
>>>>
>>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
>>>> True Else
>>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
>>>> False End If pToggleProtectDoc (ie to reprotect doc)
>>>>
>>>> This will simply hide the text in the bookmark. However, depending
>>>> on the version of Word and the user's display settings, the text
>>>> may still be visible on the screen - although it will be marked as
>>>> hidden. It may also print if the user sets the option to print
>>>> hidden text.
>>>>
>>>> There are better but more complex solutions possible, but I think
>>>> this should suite your needs for the moment.
>>>>
>>>> You can also add some error handling to prevent that really ugly
>>>> VBA error from being displayed. Check out the VBA help on the
>>>> .Exists method of the Bookmark object. This method can be used as
>>>> follows:
>>>>
>>>> If ActiveDocument.Bookmarks("bkxxxxx").Exists = True Then
>>>> pToggleProtectDoc (ie to unprotect doc)
>>>> If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
>>>>
>>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
>>>> True Else
>>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
>>>> False End If pToggleProtectDoc (ie to reprotect doc)
>>>> Else
>>>> MsgBox "The Bookmark " &
>>>> ActiveDocument.Bookmarks("bkxxxxx").Name & " cannot be found." &
>>>> vbCr & "Contact ItsMe for assistance.", vbCritical, "Bookmark
>>>> Error"
>>>> End If
>>>>
>>>> And one final note on your code. Not every If statement requires
>>>> an Else statement. Accordingly, your code
>>>>
>>>> Else
>>>> Exit Sub
>>>>
>>>> could be removed without effect. In this instance especially,
>>>> unless you have something else in the procedure that you do not
>>>> wish to be executed if the FormField's Result is "Yes" (or at
>>>> least not "No"), there is no need to explicitly exit the
>>>> procedure; the code will simply run to the End Sub statement and
>>>> exit of its own accord. --
>>>> Cheers!
>>>> Gordon
>>>>
>>>> Uninvited email contact will be marked as SPAM and ignored. Please
>>>> post all follow-ups to the newsgroup.
>>>>
>>>>
>>>> "ItsMe" wrote:
>>>>
>>>>> Thank you soooo very much for your quick reply. I am VEEEEEERY
>>>>> new to this so I beg your forgiveness in advance. I did add the
>>>>> command suggested (right after my "range.delete" command). It
>>>>> works in that the "requested member ... does not exist" message
>>>>> does not pop up anymore, which is very good.
>>>>>
>>>>> However, if I go back to the DD, the DD field disappears, which
>>>>> is not so good (which, I assume, is because I am re-adding the
>>>>> empty bookmark in the field where the macro that erase the
>>>>> bookmark in the first place is linked). Am I making any sense?
>>>>> Could I re-add the bookmark somewhere else where it would not
>>>>> erase the DD field if I go back to this field?
>>>>>
>>>>> And, let me push my luck a little... Ideally, in an ideal world,
>>>>> what would be the top and would make my day (and even my week --
>>>>> my year even!!!), would be to have this very complex text (ie
>>>>> with DD, fields, cross-referencing, paragraph numbering) in this
>>>>> enclosing bookmark "disappear" when the user selects "No" in the
>>>>> DD and then "reappear" should the user go back to the DD field,
>>>>> changes his mind and selects "yes" instead of "no"
>>>>>
>>>>> Any help you could provide (or reading material) would be so very
>>>>> much appreciated.
>>>>>
>>>>> "Jay Freedman" wrote:
>>>>>
>>>>>> ItsMe wrote:
>>>>>>> In a protected form, I created a macro in exiting a DD field so
>>>>>>> the content of an enclosing bookmark somewhere else in the
>>>>>>> document disappears when the user chooses "No".
>>>>>>> If ActiveDocument.FormFields("bkxxxxx").Result = "No"
>>>>>>> Then pToggleProtectDoc (ie to unprotect doc)
>>>>>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Delete
>>>>>>> pToggleProtectDoc (ie to reprotect doc)
>>>>>>> Else
>>>>>>> Exit Sub
>>>>>>> End If
>>>>>>> Everything works perfectly fine except that if I somehow go
>>>>>>> back to the DD field, of course this message pops up:
>>>>>>> "requested member of collection does not exist".
>>>>>>>
>>>>>>> Is there a line that I could add to my macro to prevent this.
>>>>>>>
>>>>>>> Thanks in advance.
>>>>>>
>>>>>> If there's any possibility that this code can be executed more
>>>>>> than once, then you have to re-insert the empty bookmark after
>>>>>> removing its text content. See
>>>>>> http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm
>>>>>> for the technique.
>>>>>>
>>>>>> --
>>>>>> Regards,
>>>>>> Jay Freedman
>>>>>> Microsoft Word MVP FAQ: http://word.mvps.org
>>>>>> Email cannot be acknowledged; please post all follow-ups to the
>>>>>> newsgroup so all may benefit.
--
Greg Maxey - Word MVP
My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org
date: Thu, 21 Aug 2008 10:23:13 -0400
author: Greg Maxey RrOMEOgOLF
Re: Bookmarks - Requested member of collection does not exist
Thanks Greg. I'll have a look. Knew I could count on you to have some insight
into this issue.
--
Cheers!
Gordon
Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
"Greg Maxey" wrote:
> Gordon/Carmen
>
> You both might have a look at:
> http://gregmaxey.mvps.org/Toggle_Data_Display.htm. I think you could adapt
> it to toggle with the results of a formfield.
>
>
>
> ItsMe wrote:
> > Hi Gordon,
> > You are driving me crazy. This just goes to show how little I know.
> > NewZealand... very exotic I'd imagine but quite far from my Montreal
> > Québec where we are having the worst summer ever by the way. So far
> > yet so close. I will look at all that over the w-end and try a few
> > things, hopefully with some success (if the "luck of the beginner"
> > kicks in). Hidden text shouldn't be a problem since none of them
> > really knows Word at all.
> >
> > You are all (mostly same group of people seem to reply to these
> > desperate posts) very vey nice and exceptionally giving of your time.
> > Thank you and thank God you are there...
> >
> > "Gordon Bentley-Mix" wrote:
> >
> >> Carmen,
> >>
> >> I'm afraid you'd have to move to New Zealand to share an office. ;-p
> >>
> >> You could still use the "hidden" text option if you're willing to
> >> jump through a few hoops. You could always fiddle with the "View"
> >> settings to make sure that hidden text isn't displayed after the
> >> document is built - but this is something that I don't generally
> >> like to do as users tend to get a bit cross if settings start
> >> changing without them knowing why. That said, most users aren't any
> >> the wiser if hidden text is... well... hidden, so maybe you could
> >> get away with this. Those that do want to see hidden text usually
> >> know how to go about displaying it again. (A couple of tips on this
> >> approach: look at the View property of the ActiveWindow object and
> >> be aware that ShowAll will have an role to play as well.)
> >>
> >> As for printing, you could write FilePrint and FilePrintDefault
> >> procedures into the template that would ensure that hidden text
> >> isn't printed. If you search on "FilePrintDefault" you'll find a
> >> recent post called "VBA to change Display for Review setting" in
> >> which Jay Freedman discusses writing these procedures. From there
> >> it's just a matter of poking around in the VBA help until you find
> >> the setting for making sure hidden text isn't printed. The nice
> >> thing about this approach is that it should be document-specific, so
> >> it shouldn't have an impact on the printing of any other document.
> >>
> >> (Just quietly, I think you could probably get away with this approach
> >> without too much complaint from anyone; hiding and not printing
> >> hidden text is actually the default, so if you just enforced it with
> >> code...) --
> >> Cheers!
> >> Gordon
> >>
> >> Uninvited email contact will be marked as SPAM and ignored. Please
> >> post all follow-ups to the newsgroup.
> >>
> >>
> >> "ItsMe" wrote:
> >>
> >>> I am totally jealous Gordon -- wish I were as proficient and had
> >>> more time to explore all that. I had thought of something along the
> >>> lines of "hidden" but too many users, too many settings and at
> >>> least 3 different versions of Word (2000-02 & 03) and it is
> >>> imperative that the hidden text does not show on printing.
> >>>
> >>> I used this .Exists("bkxxx") line and it solved the message
> >>> problem. Thanks a million for your pointers. It is complex indeed
> >>> b/c, of course, when I go back to the DD field and re-choose "yes",
> >>> text does not reappear. I will explore a temporary solution (if it
> >>> exists???) whereby I will deactivate the field once the user has
> >>> selected his answer.
> >>>
> >>> Needless to say that if you ever find yourself with nothing to do
> >>> (hihi) and way too much time on your hands (hihi) and wish to help
> >>> me with this complex disappearing act, I would be forever grateful.
> >>> Boy, do I wish we were in the same office !!!
> >>> Carmen
> >>>
> >>> "Gordon Bentley-Mix" wrote:
> >>>
> >>>> There is a simple - altho possible not ideal - solution to making
> >>>> the text in the bookmark "disappear" and "reappear". Rewrite your
> >>>> sub as follows:
> >>>>
> >>>> pToggleProtectDoc (ie to unprotect doc)
> >>>> If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> >>>>
> >>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
> >>>> True Else
> >>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
> >>>> False End If pToggleProtectDoc (ie to reprotect doc)
> >>>>
> >>>> This will simply hide the text in the bookmark. However, depending
> >>>> on the version of Word and the user's display settings, the text
> >>>> may still be visible on the screen - although it will be marked as
> >>>> hidden. It may also print if the user sets the option to print
> >>>> hidden text.
> >>>>
> >>>> There are better but more complex solutions possible, but I think
> >>>> this should suite your needs for the moment.
> >>>>
> >>>> You can also add some error handling to prevent that really ugly
> >>>> VBA error from being displayed. Check out the VBA help on the
> >>>> .Exists method of the Bookmark object. This method can be used as
> >>>> follows:
> >>>>
> >>>> If ActiveDocument.Bookmarks("bkxxxxx").Exists = True Then
> >>>> pToggleProtectDoc (ie to unprotect doc)
> >>>> If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> >>>>
> >>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
> >>>> True Else
> >>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
> >>>> False End If pToggleProtectDoc (ie to reprotect doc)
> >>>> Else
> >>>> MsgBox "The Bookmark " &
> >>>> ActiveDocument.Bookmarks("bkxxxxx").Name & " cannot be found." &
> >>>> vbCr & "Contact ItsMe for assistance.", vbCritical, "Bookmark
> >>>> Error"
> >>>> End If
> >>>>
> >>>> And one final note on your code. Not every If statement requires
> >>>> an Else statement. Accordingly, your code
> >>>>
> >>>> Else
> >>>> Exit Sub
> >>>>
> >>>> could be removed without effect. In this instance especially,
> >>>> unless you have something else in the procedure that you do not
> >>>> wish to be executed if the FormField's Result is "Yes" (or at
> >>>> least not "No"), there is no need to explicitly exit the
> >>>> procedure; the code will simply run to the End Sub statement and
> >>>> exit of its own accord. --
> >>>> Cheers!
> >>>> Gordon
> >>>>
> >>>> Uninvited email contact will be marked as SPAM and ignored. Please
> >>>> post all follow-ups to the newsgroup.
> >>>>
> >>>>
> >>>> "ItsMe" wrote:
> >>>>
> >>>>> Thank you soooo very much for your quick reply. I am VEEEEEERY
> >>>>> new to this so I beg your forgiveness in advance. I did add the
> >>>>> command suggested (right after my "range.delete" command). It
> >>>>> works in that the "requested member ... does not exist" message
> >>>>> does not pop up anymore, which is very good.
> >>>>>
> >>>>> However, if I go back to the DD, the DD field disappears, which
> >>>>> is not so good (which, I assume, is because I am re-adding the
> >>>>> empty bookmark in the field where the macro that erase the
> >>>>> bookmark in the first place is linked). Am I making any sense?
> >>>>> Could I re-add the bookmark somewhere else where it would not
> >>>>> erase the DD field if I go back to this field?
> >>>>>
> >>>>> And, let me push my luck a little... Ideally, in an ideal world,
> >>>>> what would be the top and would make my day (and even my week --
> >>>>> my year even!!!), would be to have this very complex text (ie
> >>>>> with DD, fields, cross-referencing, paragraph numbering) in this
> >>>>> enclosing bookmark "disappear" when the user selects "No" in the
> >>>>> DD and then "reappear" should the user go back to the DD field,
> >>>>> changes his mind and selects "yes" instead of "no"
> >>>>>
> >>>>> Any help you could provide (or reading material) would be so very
> >>>>> much appreciated.
> >>>>>
> >>>>> "Jay Freedman" wrote:
> >>>>>
> >>>>>> ItsMe wrote:
> >>>>>>> In a protected form, I created a macro in exiting a DD field so
> >>>>>>> the content of an enclosing bookmark somewhere else in the
> >>>>>>> document disappears when the user chooses "No".
> >>>>>>> If ActiveDocument.FormFields("bkxxxxx").Result = "No"
> >>>>>>> Then pToggleProtectDoc (ie to unprotect doc)
> >>>>>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Delete
> >>>>>>> pToggleProtectDoc (ie to reprotect doc)
> >>>>>>> Else
> >>>>>>> Exit Sub
> >>>>>>> End If
> >>>>>>> Everything works perfectly fine except that if I somehow go
> >>>>>>> back to the DD field, of course this message pops up:
> >>>>>>> "requested member of collection does not exist".
> >>>>>>>
> >>>>>>> Is there a line that I could add to my macro to prevent this.
> >>>>>>>
> >>>>>>> Thanks in advance.
> >>>>>>
> >>>>>> If there's any possibility that this code can be executed more
> >>>>>> than once, then you have to re-insert the empty bookmark after
> >>>>>> removing its text content. See
> >>>>>> http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm
> >>>>>> for the technique.
> >>>>>>
> >>>>>> --
> >>>>>> Regards,
> >>>>>> Jay Freedman
> >>>>>> Microsoft Word MVP FAQ: http://word.mvps.org
> >>>>>> Email cannot be acknowledged; please post all follow-ups to the
> >>>>>> newsgroup so all may benefit.
>
> --
> Greg Maxey - Word MVP
>
> My web site http://gregmaxey.mvps.org
> Word MVP web site http://word.mvps.org
>
>
>
date: Thu, 21 Aug 2008 16:27:01 -0700
author: Gordon Bentley-Mix gordon(dot)bentleymix(at)gmail(dot)com
Re: Bookmarks - Requested member of collection does not exist
I don't believe how nice you are all (not to mention proficient and
friendly). Thank you so very much. For now, since it's kinda the first nice
day of the summer (which is ending !!!) I will step outside for a boost of
vitamin D and work on that tonight. Lots of work ahead of me I suspect but I
am confident. Thanks again for your help.. your quick help. Will let you know
how it turns out.
Carmen
"Gordon Bentley-Mix" wrote:
> Thanks Greg. I'll have a look. Knew I could count on you to have some insight
> into this issue.
> --
> Cheers!
> Gordon
>
> Uninvited email contact will be marked as SPAM and ignored. Please post all
> follow-ups to the newsgroup.
>
>
> "Greg Maxey" wrote:
>
> > Gordon/Carmen
> >
> > You both might have a look at:
> > http://gregmaxey.mvps.org/Toggle_Data_Display.htm. I think you could adapt
> > it to toggle with the results of a formfield.
> >
> >
> >
> > ItsMe wrote:
> > > Hi Gordon,
> > > You are driving me crazy. This just goes to show how little I know.
> > > NewZealand... very exotic I'd imagine but quite far from my Montreal
> > > Québec where we are having the worst summer ever by the way. So far
> > > yet so close. I will look at all that over the w-end and try a few
> > > things, hopefully with some success (if the "luck of the beginner"
> > > kicks in). Hidden text shouldn't be a problem since none of them
> > > really knows Word at all.
> > >
> > > You are all (mostly same group of people seem to reply to these
> > > desperate posts) very vey nice and exceptionally giving of your time.
> > > Thank you and thank God you are there...
> > >
> > > "Gordon Bentley-Mix" wrote:
> > >
> > >> Carmen,
> > >>
> > >> I'm afraid you'd have to move to New Zealand to share an office. ;-p
> > >>
> > >> You could still use the "hidden" text option if you're willing to
> > >> jump through a few hoops. You could always fiddle with the "View"
> > >> settings to make sure that hidden text isn't displayed after the
> > >> document is built - but this is something that I don't generally
> > >> like to do as users tend to get a bit cross if settings start
> > >> changing without them knowing why. That said, most users aren't any
> > >> the wiser if hidden text is... well... hidden, so maybe you could
> > >> get away with this. Those that do want to see hidden text usually
> > >> know how to go about displaying it again. (A couple of tips on this
> > >> approach: look at the View property of the ActiveWindow object and
> > >> be aware that ShowAll will have an role to play as well.)
> > >>
> > >> As for printing, you could write FilePrint and FilePrintDefault
> > >> procedures into the template that would ensure that hidden text
> > >> isn't printed. If you search on "FilePrintDefault" you'll find a
> > >> recent post called "VBA to change Display for Review setting" in
> > >> which Jay Freedman discusses writing these procedures. From there
> > >> it's just a matter of poking around in the VBA help until you find
> > >> the setting for making sure hidden text isn't printed. The nice
> > >> thing about this approach is that it should be document-specific, so
> > >> it shouldn't have an impact on the printing of any other document.
> > >>
> > >> (Just quietly, I think you could probably get away with this approach
> > >> without too much complaint from anyone; hiding and not printing
> > >> hidden text is actually the default, so if you just enforced it with
> > >> code...) --
> > >> Cheers!
> > >> Gordon
> > >>
> > >> Uninvited email contact will be marked as SPAM and ignored. Please
> > >> post all follow-ups to the newsgroup.
> > >>
> > >>
> > >> "ItsMe" wrote:
> > >>
> > >>> I am totally jealous Gordon -- wish I were as proficient and had
> > >>> more time to explore all that. I had thought of something along the
> > >>> lines of "hidden" but too many users, too many settings and at
> > >>> least 3 different versions of Word (2000-02 & 03) and it is
> > >>> imperative that the hidden text does not show on printing.
> > >>>
> > >>> I used this .Exists("bkxxx") line and it solved the message
> > >>> problem. Thanks a million for your pointers. It is complex indeed
> > >>> b/c, of course, when I go back to the DD field and re-choose "yes",
> > >>> text does not reappear. I will explore a temporary solution (if it
> > >>> exists???) whereby I will deactivate the field once the user has
> > >>> selected his answer.
> > >>>
> > >>> Needless to say that if you ever find yourself with nothing to do
> > >>> (hihi) and way too much time on your hands (hihi) and wish to help
> > >>> me with this complex disappearing act, I would be forever grateful.
> > >>> Boy, do I wish we were in the same office !!!
> > >>> Carmen
> > >>>
> > >>> "Gordon Bentley-Mix" wrote:
> > >>>
> > >>>> There is a simple - altho possible not ideal - solution to making
> > >>>> the text in the bookmark "disappear" and "reappear". Rewrite your
> > >>>> sub as follows:
> > >>>>
> > >>>> pToggleProtectDoc (ie to unprotect doc)
> > >>>> If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > >>>>
> > >>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
> > >>>> True Else
> > >>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
> > >>>> False End If pToggleProtectDoc (ie to reprotect doc)
> > >>>>
> > >>>> This will simply hide the text in the bookmark. However, depending
> > >>>> on the version of Word and the user's display settings, the text
> > >>>> may still be visible on the screen - although it will be marked as
> > >>>> hidden. It may also print if the user sets the option to print
> > >>>> hidden text.
> > >>>>
> > >>>> There are better but more complex solutions possible, but I think
> > >>>> this should suite your needs for the moment.
> > >>>>
> > >>>> You can also add some error handling to prevent that really ugly
> > >>>> VBA error from being displayed. Check out the VBA help on the
> > >>>> .Exists method of the Bookmark object. This method can be used as
> > >>>> follows:
> > >>>>
> > >>>> If ActiveDocument.Bookmarks("bkxxxxx").Exists = True Then
> > >>>> pToggleProtectDoc (ie to unprotect doc)
> > >>>> If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > >>>>
> > >>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
> > >>>> True Else
> > >>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
> > >>>> False End If pToggleProtectDoc (ie to reprotect doc)
> > >>>> Else
> > >>>> MsgBox "The Bookmark " &
> > >>>> ActiveDocument.Bookmarks("bkxxxxx").Name & " cannot be found." &
> > >>>> vbCr & "Contact ItsMe for assistance.", vbCritical, "Bookmark
> > >>>> Error"
> > >>>> End If
> > >>>>
> > >>>> And one final note on your code. Not every If statement requires
> > >>>> an Else statement. Accordingly, your code
> > >>>>
> > >>>> Else
> > >>>> Exit Sub
> > >>>>
> > >>>> could be removed without effect. In this instance especially,
> > >>>> unless you have something else in the procedure that you do not
> > >>>> wish to be executed if the FormField's Result is "Yes" (or at
> > >>>> least not "No"), there is no need to explicitly exit the
> > >>>> procedure; the code will simply run to the End Sub statement and
> > >>>> exit of its own accord. --
> > >>>> Cheers!
> > >>>> Gordon
> > >>>>
> > >>>> Uninvited email contact will be marked as SPAM and ignored. Please
> > >>>> post all follow-ups to the newsgroup.
> > >>>>
> > >>>>
> > >>>> "ItsMe" wrote:
> > >>>>
> > >>>>> Thank you soooo very much for your quick reply. I am VEEEEEERY
> > >>>>> new to this so I beg your forgiveness in advance. I did add the
> > >>>>> command suggested (right after my "range.delete" command). It
> > >>>>> works in that the "requested member ... does not exist" message
> > >>>>> does not pop up anymore, which is very good.
> > >>>>>
> > >>>>> However, if I go back to the DD, the DD field disappears, which
> > >>>>> is not so good (which, I assume, is because I am re-adding the
> > >>>>> empty bookmark in the field where the macro that erase the
> > >>>>> bookmark in the first place is linked). Am I making any sense?
> > >>>>> Could I re-add the bookmark somewhere else where it would not
> > >>>>> erase the DD field if I go back to this field?
> > >>>>>
> > >>>>> And, let me push my luck a little... Ideally, in an ideal world,
> > >>>>> what would be the top and would make my day (and even my week --
> > >>>>> my year even!!!), would be to have this very complex text (ie
> > >>>>> with DD, fields, cross-referencing, paragraph numbering) in this
> > >>>>> enclosing bookmark "disappear" when the user selects "No" in the
> > >>>>> DD and then "reappear" should the user go back to the DD field,
> > >>>>> changes his mind and selects "yes" instead of "no"
> > >>>>>
> > >>>>> Any help you could provide (or reading material) would be so very
> > >>>>> much appreciated.
> > >>>>>
> > >>>>> "Jay Freedman" wrote:
> > >>>>>
> > >>>>>> ItsMe wrote:
> > >>>>>>> In a protected form, I created a macro in exiting a DD field so
> > >>>>>>> the content of an enclosing bookmark somewhere else in the
> > >>>>>>> document disappears when the user chooses "No".
> > >>>>>>> If ActiveDocument.FormFields("bkxxxxx").Result = "No"
> > >>>>>>> Then pToggleProtectDoc (ie to unprotect doc)
> > >>>>>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Delete
> > >>>>>>> pToggleProtectDoc (ie to reprotect doc)
> > >>>>>>> Else
> > >>>>>>> Exit Sub
> > >>>>>>> End If
> > >>>>>>> Everything works perfectly fine except that if I somehow go
> > >>>>>>> back to the DD field, of course this message pops up:
> > >>>>>>> "requested member of collection does not exist".
> > >>>>>>>
> > >>>>>>> Is there a line that I could add to my macro to prevent this.
> > >>>>>>>
> > >>>>>>> Thanks in advance.
> > >>>>>>
> > >>>>>> If there's any possibility that this code can be executed more
> > >>>>>> than once, then you have to re-insert the empty bookmark after
> > >>>>>> removing its text content. See
> > >>>>>> http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm
> > >>>>>> for the technique.
> > >>>>>>
> > >>>>>> --
> > >>>>>> Regards,
> > >>>>>> Jay Freedman
> > >>>>>> Microsoft Word MVP FAQ: http://word.mvps.org
> > >>>>>> Email cannot be acknowledged; please post all follow-ups to the
> > >>>>>> newsgroup so all may benefit.
> >
> > --
> > Greg Maxey - Word MVP
> >
> > My web site http://gregmaxey.mvps.org
> > Word MVP web site http://word.mvps.org
> >
> >
> >
date: Fri, 22 Aug 2008 08:23:01 -0700
author: C''''est_moi
Re: Bookmarks - Requested member of collection does not exist
Hi Gordon
Me again. I have tried your suggestion and I must say I love you... I feel
kinda proficient myself suddenly, thanks to you !!!
It works on many forms that I have. For my use, your suggestion is simpler
than Greg's. I also tried the
"ActiveDocument.ActiveWindow.View.ShowHiddenText" line which works as well,
except (isn't there always something else???) where I have a DDfield that
must disappear/reappear along with the rest of the text.
If the DDfield is enclosed in the bookmark that I hide, it still remains
visible while the rest of the bookmark text does disappear.
If I choose to hide everything with "HiddenText" (then have it show or hide
with the above line), then the DDfield does disappear and reappears --
alleluia!!! -- but becomes disabled (I assume b/c it is hidden in the first
place).
Should you have any idea as to how this could be solve, I don't even know
what words I will be using to thank you...
"C''''est_moi" wrote:
> I don't believe how nice you are all (not to mention proficient and
> friendly). Thank you so very much. For now, since it's kinda the first nice
> day of the summer (which is ending !!!) I will step outside for a boost of
> vitamin D and work on that tonight. Lots of work ahead of me I suspect but I
> am confident. Thanks again for your help.. your quick help. Will let you know
> how it turns out.
> Carmen
>
> "Gordon Bentley-Mix" wrote:
>
> > Thanks Greg. I'll have a look. Knew I could count on you to have some insight
> > into this issue.
> > --
> > Cheers!
> > Gordon
> >
> > Uninvited email contact will be marked as SPAM and ignored. Please post all
> > follow-ups to the newsgroup.
> >
> >
> > "Greg Maxey" wrote:
> >
> > > Gordon/Carmen
> > >
> > > You both might have a look at:
> > > http://gregmaxey.mvps.org/Toggle_Data_Display.htm. I think you could adapt
> > > it to toggle with the results of a formfield.
> > >
> > >
> > >
> > > ItsMe wrote:
> > > > Hi Gordon,
> > > > You are driving me crazy. This just goes to show how little I know.
> > > > NewZealand... very exotic I'd imagine but quite far from my Montreal
> > > > Québec where we are having the worst summer ever by the way. So far
> > > > yet so close. I will look at all that over the w-end and try a few
> > > > things, hopefully with some success (if the "luck of the beginner"
> > > > kicks in). Hidden text shouldn't be a problem since none of them
> > > > really knows Word at all.
> > > >
> > > > You are all (mostly same group of people seem to reply to these
> > > > desperate posts) very vey nice and exceptionally giving of your time.
> > > > Thank you and thank God you are there...
> > > >
> > > > "Gordon Bentley-Mix" wrote:
> > > >
> > > >> Carmen,
> > > >>
> > > >> I'm afraid you'd have to move to New Zealand to share an office. ;-p
> > > >>
> > > >> You could still use the "hidden" text option if you're willing to
> > > >> jump through a few hoops. You could always fiddle with the "View"
> > > >> settings to make sure that hidden text isn't displayed after the
> > > >> document is built - but this is something that I don't generally
> > > >> like to do as users tend to get a bit cross if settings start
> > > >> changing without them knowing why. That said, most users aren't any
> > > >> the wiser if hidden text is... well... hidden, so maybe you could
> > > >> get away with this. Those that do want to see hidden text usually
> > > >> know how to go about displaying it again. (A couple of tips on this
> > > >> approach: look at the View property of the ActiveWindow object and
> > > >> be aware that ShowAll will have an role to play as well.)
> > > >>
> > > >> As for printing, you could write FilePrint and FilePrintDefault
> > > >> procedures into the template that would ensure that hidden text
> > > >> isn't printed. If you search on "FilePrintDefault" you'll find a
> > > >> recent post called "VBA to change Display for Review setting" in
> > > >> which Jay Freedman discusses writing these procedures. From there
> > > >> it's just a matter of poking around in the VBA help until you find
> > > >> the setting for making sure hidden text isn't printed. The nice
> > > >> thing about this approach is that it should be document-specific, so
> > > >> it shouldn't have an impact on the printing of any other document.
> > > >>
> > > >> (Just quietly, I think you could probably get away with this approach
> > > >> without too much complaint from anyone; hiding and not printing
> > > >> hidden text is actually the default, so if you just enforced it with
> > > >> code...) --
> > > >> Cheers!
> > > >> Gordon
> > > >>
> > > >> Uninvited email contact will be marked as SPAM and ignored. Please
> > > >> post all follow-ups to the newsgroup.
> > > >>
> > > >>
> > > >> "ItsMe" wrote:
> > > >>
> > > >>> I am totally jealous Gordon -- wish I were as proficient and had
> > > >>> more time to explore all that. I had thought of something along the
> > > >>> lines of "hidden" but too many users, too many settings and at
> > > >>> least 3 different versions of Word (2000-02 & 03) and it is
> > > >>> imperative that the hidden text does not show on printing.
> > > >>>
> > > >>> I used this .Exists("bkxxx") line and it solved the message
> > > >>> problem. Thanks a million for your pointers. It is complex indeed
> > > >>> b/c, of course, when I go back to the DD field and re-choose "yes",
> > > >>> text does not reappear. I will explore a temporary solution (if it
> > > >>> exists???) whereby I will deactivate the field once the user has
> > > >>> selected his answer.
> > > >>>
> > > >>> Needless to say that if you ever find yourself with nothing to do
> > > >>> (hihi) and way too much time on your hands (hihi) and wish to help
> > > >>> me with this complex disappearing act, I would be forever grateful.
> > > >>> Boy, do I wish we were in the same office !!!
> > > >>> Carmen
> > > >>>
> > > >>> "Gordon Bentley-Mix" wrote:
> > > >>>
> > > >>>> There is a simple - altho possible not ideal - solution to making
> > > >>>> the text in the bookmark "disappear" and "reappear". Rewrite your
> > > >>>> sub as follows:
> > > >>>>
> > > >>>> pToggleProtectDoc (ie to unprotect doc)
> > > >>>> If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > > >>>>
> > > >>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
> > > >>>> True Else
> > > >>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
> > > >>>> False End If pToggleProtectDoc (ie to reprotect doc)
> > > >>>>
> > > >>>> This will simply hide the text in the bookmark. However, depending
> > > >>>> on the version of Word and the user's display settings, the text
> > > >>>> may still be visible on the screen - although it will be marked as
> > > >>>> hidden. It may also print if the user sets the option to print
> > > >>>> hidden text.
> > > >>>>
> > > >>>> There are better but more complex solutions possible, but I think
> > > >>>> this should suite your needs for the moment.
> > > >>>>
> > > >>>> You can also add some error handling to prevent that really ugly
> > > >>>> VBA error from being displayed. Check out the VBA help on the
> > > >>>> .Exists method of the Bookmark object. This method can be used as
> > > >>>> follows:
> > > >>>>
> > > >>>> If ActiveDocument.Bookmarks("bkxxxxx").Exists = True Then
> > > >>>> pToggleProtectDoc (ie to unprotect doc)
> > > >>>> If ActiveDocument.FormFields("bkxxxxx").Result = "No" Then
> > > >>>>
> > > >>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
> > > >>>> True Else
> > > >>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Font.Hidden =
> > > >>>> False End If pToggleProtectDoc (ie to reprotect doc)
> > > >>>> Else
> > > >>>> MsgBox "The Bookmark " &
> > > >>>> ActiveDocument.Bookmarks("bkxxxxx").Name & " cannot be found." &
> > > >>>> vbCr & "Contact ItsMe for assistance.", vbCritical, "Bookmark
> > > >>>> Error"
> > > >>>> End If
> > > >>>>
> > > >>>> And one final note on your code. Not every If statement requires
> > > >>>> an Else statement. Accordingly, your code
> > > >>>>
> > > >>>> Else
> > > >>>> Exit Sub
> > > >>>>
> > > >>>> could be removed without effect. In this instance especially,
> > > >>>> unless you have something else in the procedure that you do not
> > > >>>> wish to be executed if the FormField's Result is "Yes" (or at
> > > >>>> least not "No"), there is no need to explicitly exit the
> > > >>>> procedure; the code will simply run to the End Sub statement and
> > > >>>> exit of its own accord. --
> > > >>>> Cheers!
> > > >>>> Gordon
> > > >>>>
> > > >>>> Uninvited email contact will be marked as SPAM and ignored. Please
> > > >>>> post all follow-ups to the newsgroup.
> > > >>>>
> > > >>>>
> > > >>>> "ItsMe" wrote:
> > > >>>>
> > > >>>>> Thank you soooo very much for your quick reply. I am VEEEEEERY
> > > >>>>> new to this so I beg your forgiveness in advance. I did add the
> > > >>>>> command suggested (right after my "range.delete" command). It
> > > >>>>> works in that the "requested member ... does not exist" message
> > > >>>>> does not pop up anymore, which is very good.
> > > >>>>>
> > > >>>>> However, if I go back to the DD, the DD field disappears, which
> > > >>>>> is not so good (which, I assume, is because I am re-adding the
> > > >>>>> empty bookmark in the field where the macro that erase the
> > > >>>>> bookmark in the first place is linked). Am I making any sense?
> > > >>>>> Could I re-add the bookmark somewhere else where it would not
> > > >>>>> erase the DD field if I go back to this field?
> > > >>>>>
> > > >>>>> And, let me push my luck a little... Ideally, in an ideal world,
> > > >>>>> what would be the top and would make my day (and even my week --
> > > >>>>> my year even!!!), would be to have this very complex text (ie
> > > >>>>> with DD, fields, cross-referencing, paragraph numbering) in this
> > > >>>>> enclosing bookmark "disappear" when the user selects "No" in the
> > > >>>>> DD and then "reappear" should the user go back to the DD field,
> > > >>>>> changes his mind and selects "yes" instead of "no"
> > > >>>>>
> > > >>>>> Any help you could provide (or reading material) would be so very
> > > >>>>> much appreciated.
> > > >>>>>
> > > >>>>> "Jay Freedman" wrote:
> > > >>>>>
> > > >>>>>> ItsMe wrote:
> > > >>>>>>> In a protected form, I created a macro in exiting a DD field so
> > > >>>>>>> the content of an enclosing bookmark somewhere else in the
> > > >>>>>>> document disappears when the user chooses "No".
> > > >>>>>>> If ActiveDocument.FormFields("bkxxxxx").Result = "No"
> > > >>>>>>> Then pToggleProtectDoc (ie to unprotect doc)
> > > >>>>>>> ActiveDocument.Bookmarks("bkxxxxx").Range.Delete
> > > >>>>>>> pToggleProtectDoc (ie to reprotect doc)
> > > >>>>>>> Else
> > > >>>>>>> Exit Sub
> > > >>>>>>> End If
> > > >>>>>>> Everything works perfectly fine except that if I somehow go
> > > >>>>>>> back to the DD field, of course this message pops up:
> > > >>>>>>> "requested member of collection does not exist".
> > > >>>>>>>
> > > >>>>>>> Is there a line that I could add to my macro to prevent this.
> > > >>>>>>>
> > > >>>>>>> Thanks in advance.
> > > >>>>>>
> > > >>>>>> If there's any possibility that this code can be executed more
> > > >>>>>> than once, then you have to re-insert the empty bookmark after
> > > >>>>>> removing its text content. See
> > > >>>>>> http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm
> > > >>>>>> for the technique.
> > > >>>>>>
> > > >>>>>> --
> > > >>>>>> Regards,
> > > >>>>>> Jay Freedman
> > > >>>>>> Microsoft Word MVP FAQ: http://word.mvps.org
> > > >>>>>> Email cannot be acknowledged; please post all follow-ups to the
> > > >>>>>> newsgroup so all may benefit.
> > >
> > > --
> > > Greg Maxey - Word MVP
> > >
> > > My web site http://gregmaxey.mvps.org
> > > Word MVP web site http://word.mvps.org
> > >
> > >
> > >
date: Mon, 25 Aug 2008 09:02:02 -0700
author: ItsMe
|
|