dcsimg
Results 1 to 13 of 13

Thread: What external change could prevent macros from working?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    8

    What external change could prevent macros from working?

    I maintain an application that manages budgets written in the mid 90s. For some reason, the macros stopped working. We get bogus compiler errors. If you comment out that line you will get another bogus compiler error. If we build a new macro that works OK. The macros are in a template for Word. When the macro executes it is on the users profile.

    This problem showed up while IT was moving stuff from the LAN to the cloud. It shouldn’t have affected us but I suspect some resource could have been moved. IT will not share what they moved or even provide an Office expert to help. We all have the latest version of Office, but we have different Oss.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,882

    Re: What external change could prevent macros from working?

    i would first look for any missing reference

    menu > tools > references

    a symptom of have a missing reference is if you prefix any erroring statement with vba. if will then run
    eg mid with vba.mid etc
    this can happen even if the missing reference has nothing to do with the actual errors

    remove any missing reference and try to re-add it
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    8

    Re: What external change could prevent macros from working?

    Thank you for the reply

    Yes, I believe something has been moved.

    Is

    menu > tools > references
    in VBA?

    I don't have a copy of VB at work. Our company does have a .Net programmer working on a different contract. We share the same boss so I will pass this along.

    Thanks! This is a good tip.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,882

    Re: What external change could prevent macros from working?

    menu > tools > references
    in VBA?
    yes vba, different menu in vb6, .net is completely different

    as you called them macros i assumed you were coding in VBA

    I don't have a copy of VB at work. Our company does have a .Net programmer working on a different contract.
    i doubt that will help if he does not have the source code, or if it is in a different programing language
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    8

    Re: What external change could prevent macros from working?

    Thanks again for the kind response. There are 2 parts most of the code is in 2 different languages but that is my expertise not VB. The client has one of the better debuggers I have ever used. None of this is at issue. The code not VBA continues to work fine it is the macro that is the problem. I have not asked to develop macros I merely maintain them. Sometimes they want to change the wording in a spot due to a nuance in the federal budget. There needs to be different words if we are under a continuing resolution. There is usually a few small changes to be made every year but there are no major changes. These changes are all done by a find and replace. Which is only done when everything is text. The budget years are variables to start with. When I make changes I just go to the macro section select AutoOpen and make the changes. Fortunately, previous changes are still there commented out. I just need to find the fix that matches my instructions. I copy the change because some times I need to change what should work a bit to get it to work. You can see all the variations of the fixes which is more valuable than any book. I assume that is VBA. It is very Spartan no bells and whistles. It compiles and will throw compiler errors but that is about it.

    Here is the snippet that causes trouble.

    ls_EZBwork_directory = Environ("USERPROFILE") + "\EZBWORK"
    ls_EZBudget_ini = ls_EZBwork_directory + "\EZBUDGET.INI"

    'V6.1 Supriya 06/06/07 WR #53# By default turn off the tracking feature
    'On Error Resume Next
    'ActiveDocument.TrackRevisions = False
    'V6.7 Supriya 08/29/2012 WR #192# stop automatically accepting the revisions
    lb_previous_track_revision = False
    On Error Resume Next
    lb_previous_track_revision = ActiveDocument.TrackRevisions

    'Rem 06/08/2012 #154# v6.7 update issuance Table in Issuance Document
    Inside_issuance_ezb = System.PrivateProfileString(ls_EZBudget_ini, "ISSUANCE", "INSIDE_EZB")

    The last line throws a compile error. I had suspected it was due to a function call, since it is the first function call in the macro. Now I more suspect it does not like ls_EZBudget_ini. The profiles were moved at about the same time as the problems occurred. Part of nailing down when the problem started is unless you try to run a macro you don't see the problem.

    I get into VBA through the document. How would I even find the references? I assume all the tools I have are on the left side of the VBA/debugger window.

    Thanks!

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    8

    Re: What external change could prevent macros from working?

    Thanks again for the kind response. There are 2 parts most of the code is in 2 different languages but that is my expertise not VB. The client has one of the better debuggers I have ever used. None of this is at issue. The code not VBA continues to work fine it is the macro that is the problem. I have not asked to develop macros I merely maintain them. Sometimes they want to change the wording in a spot due to a nuance in the federal budget. There needs to be different words if we are under a continuing resolution. There is usually a few small changes to be made every year but there are no major changes. These changes are all done by a find and replace. Which is only done when everything is text. The budget years are variables to start with. When I make changes I just go to the macro section select AutoOpen and make the changes. Fortunately, previous changes are still there commented out. I just need to find the fix that matches my instructions. I copy the change because some times I need to change what should work a bit to get it to work. You can see all the variations of the fixes which is more valuable than any book. I assume that is VBA. It is very Spartan no bells and whistles. It compiles and will throw compiler errors but that is about it.

    Here is the snippet that causes trouble.

    ls_EZBwork_directory = Environ("USERPROFILE") + "\EZBWORK"
    ls_EZBudget_ini = ls_EZBwork_directory + "\EZBUDGET.INI"

    'V6.1 Supriya 06/06/07 WR #53# By default turn off the tracking feature
    'On Error Resume Next
    'ActiveDocument.TrackRevisions = False
    'V6.7 Supriya 08/29/2012 WR #192# stop automatically accepting the revisions
    lb_previous_track_revision = False
    On Error Resume Next
    lb_previous_track_revision = ActiveDocument.TrackRevisions

    'Rem 06/08/2012 #154# v6.7 update issuance Table in Issuance Document
    Inside_issuance_ezb = System.PrivateProfileString(ls_EZBudget_ini, "ISSUANCE", "INSIDE_EZB")

    The last line throws a compile error. I had suspected it was due to a function call, since it is the first function call in the macro. Now I more suspect it does not like ls_EZBudget_ini. The profiles were moved at about the same time as the problems occurred. Part of nailing down when the problem started is unless you try to run a macro you don't see the problem.

    I get into VBA through the document. How would I even find the references? I assume all the tools I have are on the left side of the VBA/debugger window.

    Thanks!

  7. #7
    Frenzied Member
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,209

    Re: What external change could prevent macros from working?

    Do the macros work if you actually run them from the Word document with VBA? That would return a more meaningful error message if it did not work. If they do work, then you have an error elsewhere.

    How would I even find the references?
    In the VBA editor window, on the Menu items, Tools, References.

  8. #8

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    8

    Re: What external change could prevent macros from working?

    That had crossed my mind while in a conversation but forgot it by the time it was done. I will try that right now before it it slips my mind again. I will have the ability to cherry pick what I suspect is the problem.

    Thanks for the excellent suggestion!

  9. #9

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    8

    Re: What external change could prevent macros from working?

    Not the line that threw the error. I was turning the vars into text. That was illuminating. I suspected the issue was the profile because that had been moved but that was fine. The function call returned NULL and should have returned "Yes".

  10. #10
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,882

    Re: What external change could prevent macros from working?

    Inside_issuance_ezb = System.PrivateProfileString(ls_EZBudget_ini, "ISSUANCE", "INSIDE_EZB")
    this requires no references t use
    i would check that that the ini file is in the correct path and has not been changed, still has the section issuance and key inside_ezb
    the path should be like c:\users\username\ezbwork\ezbudget.ini or documents and settiings in XP
    i do not see any other reason why it should fail
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  11. #11

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    8

    Re: What external change could prevent macros from working?

    I will be playing with this again today.

    The path of the ini was 'correct' or at least usable. It is really on the cloud but my computer 'thinks' it is on C:. That is all that matters. The macro was using the right path.

    ls_EZBwork_directory = Environ("USERPROFILE") + "\EZBWORK"
    ls_EZBudget_ini = ls_EZBwork_directory + "\EZBUDGET.INI"
    ls_EZBudget_ini converted to text was where my computer 'thinks' the ini file is. That was my biggest concern since it had been moved when this problem started.

    I will be testing other function calls. The failure was the first function call in the macro. That was my #2 concern. Which is now #1. In an hour I will know more. Even though the office is closed, I can remote in and that connection will be less crowded today.

    This discussion has been very helpful. I was pretty much overwhelmed because I had too many unknowns. As the unknowns are discarded I am becoming less confused.

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,882

    Re: What external change could prevent macros from working?

    It is really on the cloud but my computer 'thinks' it is on C:
    if the folder is virtualized then vb may not be able to see it there even if you can see it in windows explorer, i would be making some other tests to see if you can save and read any other files from that folder using VB

    a simple
    Code:
    msgbox dir(ls_EZBudget_ini)
    should return EZBUDGET.INI
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  13. #13

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    8

    Re: What external change could prevent macros from working?

    I had an error in the ini file. I had added it and not used a real file. I had a space where none was allowed. When I fixed that it worked as it should.

    application makes the document on the fly but you can save it as so the copy is not deleted when you close it in the application. That copy has the same issue if I open it on the government computer but if I send it to this computer it opens fine without compiler errors. The environment is screwed up. I have asked to be able to use a more expensive VPN which will allow me to run the application from this computer. I suspect the bug will disappear.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width