Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Aug 2001
    Location
    Lanham, Maryland
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word VBA - Testing OnAction property (WordXP)

    I am writing code to list Word toolbar button properties. All works well until I run into a built-in button whose OnAction property is not set. I get the following error message: 438 Object doesn't support this property or method. Does anyone know how I can test for this condition? Thanks.

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word VBA - Testing OnAction property (WordXP)

    Dick,

    There are a couple of ways to attack this.

    1) You could write a complete error handler for your procedure:

    Place this at the start of your procedure:

    On Error Goto HandleError:

    then just before the End Sub place these lines of code:

    Exit Sub <font color=448800>'Replace Sub with Function if it is a Function you are dealing with</font color=448800>
    HandleError:
    Seelct Case err.Number
    Case 438
    <font color=448800>'Tell Word to ignore this error and move on to the next line</font color=448800>
    Resume Next
    Case Else
    <font color=448800>'Pop up a message box with the error and exit the Procedure</font color=448800>
    MsgBox "Error " & err.Number & ", " & Err.Description
    End Select

    2) Or at the top you can just put

    On Error Resume Next

    This tells Word to move on to the next line if it encounters an error.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    Lounger
    Join Date
    Aug 2001
    Location
    Lanham, Maryland
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word VBA - Testing OnAction property (WordXP)

    Bryan,

    I used option 1 and it works like a charm. Thank you for your assistance.

Posting Permissions

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