Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Nov 2003
    Location
    Christchurch, Canterbury
    Posts
    122
    Thanks
    27
    Thanked 1 Time in 1 Post

    Subroutine intermittently is missed (Word 2003)

    A client hs been using the code for years, recently they upgraded to 2003 and the network was beefed up. Now users on the 3rd floor are intermittently experiencing problems (those on the 4th are fine). Will never do it while I'm there. Most often occurs in the stress of billing.

    Simplied code is:

    Private Sub PopulateBill()
    On Error Resume Next

    Call CreateStdLetter ' creates a document and calls FillDocProperties

    Documents.Add Template:=TemplateDir & strTemplateName, NewTemplate:=False

    <code filling in document - which works>

    Call FillDocProperties ' this call sometimes is missed
    Debug.Print "keyword: " & ActiveDocument.BuiltInDocumentProperties(wdPropert yKeywords) ' but this line is always is okay
    end sub

    Oh ho you say - it must be erroring in FillDocProperties then resuming next. Thought of that the first line is another debug statement - it never gets there!

    Private Sub FillDocProperties()
    Debug.Print "FillDocProperties for " & ActiveDocument.Name
    <blah>
    end sub

    Now there IS another Private Sub FillDocProperties in another module - but if it got confused surely it would do that code - but it doesn't seem to be doing that either. <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>

    Any ideas? Makes me pine for the joys of agriculture.

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subroutine intermittently is missed (Word 2003)

    <hr>
    but if it got confused surely it would do that code
    <hr>

    Not necessarily! I can't see what the problem might be, but you do have an On Error Resume Next at the beginning of the Sub. That statement would cause VBA to just skip any statement that in "got confused" on. It might be enlightening to either disable that line, or change it to an On Error GoTo a routine that told you that an error had occurred and what the error was.
    Legare Coleman

  3. #3
    2 Star Lounger
    Join Date
    Nov 2003
    Location
    Christchurch, Canterbury
    Posts
    122
    Thanks
    27
    Thanked 1 Time in 1 Post

    Re: Subroutine intermittently is missed (Word 2003)

    Thanks for the suggestion. I put it in and waited for the billing period, and guess what? Still skipped the subroutine but never did the On Error routine (which did a debug.print of the error)

    It's driving me nuts - I cannot reproduce it stand alone here - and despite sitting next to the users for a morning I can't reproduce it there either! They have suggested I sit in the office whenever they do billing as I seem to be some sort of charm.

  4. #4
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subroutine intermittently is missed (Word 2003)

    I would try 3 things:
    1. <LI>Rename Private Sub FillDocProperties and it's calling line(s) so that it has a unique name in the entire project.
      <LI>If that doesn't help, then export the whole module as a .bas file, delete the module from the project and import it again.
      <LI>If that didn''t cure the problem, I'd export all modules and build the template from scratch, importing all modules into the new project, to get rid of any corruption
    PS
    Maybe it's sufficient to put your picture at your co-workers desk? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  5. #5
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Subroutine intermittently is missed (Word 2003)

    I recently spent a day troubleshooting a similar problem and solved it by changing (in your code)
    <hr>Call FillDocProperties ' this call sometimes is missed
    <hr>
    to:
    Call ModuleName.FillDocProperties
    Regards
    Don

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subroutine intermittently is missed (Word 2003

    Correct.

    Does the error occur when you run the code from source in the VBIDE?
    If so, comment out the On Error Resume Next, and enable break on ALL errors.

    If th error does not occur when yu run from the VBIDE, then you'll have to put proper error handling in each sub.

Posting Permissions

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