Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Showing comments in Word doc (Win XP/OXP)

    I have a document which is create from a Word template. The creation of the document is from the AutoNew procedure.

    When the document opens I have it go to a bookmark and I wish it to display a comment that has been inserted at this bookmark.

    Can anyone help. I have been scratching my head <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29> over this for sometime!

    Cheers
    cheers

    Phil Carter

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    Do you want to display this comment in a VBA dialog box with an OK button? If so then you should be able to do something like this

    frmComment.lblComment.Caption = bmkMyBookmark.Range.Comments(1).Text

    (Asuming your form is called frmComment, the text is displayed in a label called lblComment and bmkMyBookmark is a bookmark object pointing to your bookmark)

    StuartR

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    Stuart

    Thanks for that

    I am not sure I follow. The document that is called up is a Word template (Std_Report.dot) not specifically a form. It has 32 bookmarks that mostly pick up information from our database. However, I want to allow the users to check the client address and amend it if necessary, hence the goto bmk where I have inserted a comment.

    I fully endorse your, and all the other MVPs and moderators, recognition by Woody in the latest Woody's watch.

    Cheers
    cheers

    Phil Carter

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    What code do you already have in your AutoNew procedure? Do you have an AutoOpen procedure.

    I was suggesting that you could include this code to automatically find the comment that you have bookmarked and display its text.

    StuartR

  5. #5
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    The following is in the AutoNew procedure:

    Selection.GoTo What:=wdGoToBookmark, Name:="bmk019AUAddress"
    ActiveDocument.lblComment.Caption = bmk019AUAddress.Range.Comments(1).Text
    cheers

    Phil Carter

  6. #6
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    I was suggesting that you create a userform (called frmComment). On this userform you put a label (called lblComment) and an OK button.
    The code for the OK button click is simply "Me.Hide"
    The AutoNew should include
    <font face="Georgia">
    Selection.GoTo What:=wdGoToBookmark, Name:="bmk019AUAddress"
    frmComment.lblComment.Caption = Selection.Bookmarks(1).Range.Comments(1).Text
    frmComment.Show
    Unload frmComment
    </font face=georgia>

    StuartR

  7. #7
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    Stuart

    Sorry. I misunderstood what you were saying in your last but can see where your coming from.

    Entered the code suggested but got the following message with the Text method highlighted;

    Method or data member not found (Error 461)
    cheers

    Phil Carter

  8. #8
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    Have you created a userform called frmComments?
    Has this form got a label control called lblComments?

    StuartR

  9. #9
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    Yup

    Both as you suggested in your code (frmComment + lblComment). I notice that the code just before the Text method is "Comments(1). Is this referring to the Word function?
    cheers

    Phil Carter

  10. #10
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    I was assuming that the bookmark includes a word comment. .Range.Comments(1) refers to the first comment in the range.
    Is my assumption correct?
    Can you post sufficient of your document and your macro so that we can see them?

    StuartR

  11. #11
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    I have trimmed the document dramatically and removed most of the macros
    cheers

    Phil Carter

  12. #12
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    I'm going to stand back and let Stuart keep working on this, but I couldn't restrain myself from making this suggestion. I think your users would prefer, rather than a bland message box, that Clippy pop up with the message "I'm Back!" followed by your message. <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15> It's sure to get their attention.

  13. #13
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    Thanks for the sample, this was entirely my mistake. If you replace all instances of ".Comments(1).Text" with ".Comments(1).Range.Text" then it will work.

    I like Jefferson's idea of using Clippy - but 07:00 rapidly approaches and I have to go get ready for work. Maybe later...

    StuartR

  14. #14
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    Stuart thanks again

    Replaced the code as you suggested but got a "Run time error '5941',see attached, at the line;

    frmComment.lblComment.Caption = Selection.Bookmarks(1).Range.Comments(1).Range.Tex t
    cheers

    Phil Carter

  15. #15
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Showing comments in Word doc (Win XP/OXP)

    Phil,

    This is strange because I did test this on a copy of your document, the only change I made was to the path for storing the file.

    When you get that error then either there are no bookmarks at the selection, or there are no comments in the bookmark. Can you click the debug button. Type Control-G to open the Immediate Window, and type the following commands

    ? Selection.Bookmarks.Count
    ? Selection.Bookmarks(1).Name
    ? Selection.Bookmarks(1).Comments.Count

    The ? is an abbreviation that causes VBA to do a "Debug.Print".
    What responses to you get to each command?

    StuartR

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •