+ Reply to Thread
Results 1 to 4 of 4

One Macro Breaking Another

  1. #1
    Forum Contributor
    Join Date
    11-20-2008
    Location
    UK
    Posts
    132

    One Macro Breaking Another

    Apologies in advance if this is not very well explained but I'm pretty much a total novice when it comes to VB and have only managed to get this far by searching Google for people with similar problems and modifying their solutions as well as some superb help on here.

    Anyway. I have what I think is a complex workbook with lots of macros in it performing all manner of functions. The purpose of the workbook is to generate job sheets (hence it's called Job Sheet Generator) so I launch this workbook, I click a button that resets all the cells and generates a new job number, I enter the relevant job information and then click another button and it saves it as a new workbook in the relevant clients folder with the appropriate file name. This new workbook is then the actual Job Sheet and more information is added as the job progresses and other macros come into play.

    Everything was working fine but then I decided to complicate matters. Because the workbook has so many macros in it I wanted to 'force' users to enable macros both in the Job Sheet Generator and in the Job Sheets it creates. So I created a new worksheet in the Job Sheet Generator with a message saying that macros had to be enabled and instructions on how to do this and then added another bit of VB that hid this message if macros are enabled or hid all the other worksheets if macros are not enabled.

    If I just click on the button that saves the workbook as a new Job sheet everything is fine and If I open up the resulting job sheet and don't have macros enabled it shows me the message. Equally if I do have macros enabled, it doesn't show me the message. This is exactly how I want it.

    However if, as I actually need to, I click on the button that resets all the cells in the Job Sheet Generator and generates a new job number, then enter the new information and click on the button that then saves it as a new Job sheet the job sheet doesn't appear to work in that whether I have macros enabled or not I never see the message about having to enable macros.

    So presumably there is something in the VB of the reset macro that is killing the other macro.

    This is the code for the reset and generate job number:

    Please Login or Register  to view this content.
    This is the code for the macro that saves it as a new job sheet:

    Please Login or Register  to view this content.
    All of these macros and others are in Modules 1 in the VBA project (I've no idea what that means or why it's in there but think from memory I just followed a guide that said to do that)

    This is the code that hides or reveals the enable macros message:
    Please Login or Register  to view this content.
    This code is in ThisWorkbook within the VBA Project (Again I just followed instructions on another website so don't know if this is the correct place or not)

    Can anyone see what is causing the job sheet that is generated to NOT have a working enable macro message if I've first clicked on the reset button in the generator?

    </outofmydepth>

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: One Macro Breaking Another

    Quote Originally Posted by peakoverload View Post
    Can anyone see what is causing the job sheet that is generated to NOT have a working enable macro message if I've first clicked on the reset button in the generator?

    What do you see when you open the generated workbook?

    If your macros are already enabled, you're not going to see the enable macro message. Understand that the enable macros setting is not for each workbook. It is an application setting. So once a user enables macros on their Excel application, all workbooks will then open with macros enabled.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    11-20-2008
    Location
    UK
    Posts
    132

    Re: One Macro Breaking Another

    In testing if after I generate the new job sheet I then turn off macros, exit Excel and then open the generated job sheet I should see the message telling me to enable macros. Instead I see the job sheet like I would if macros were enabled.

    This has happened a number of times in my testing. However currently it appears to be working fine in that I've successfully generated 4 job sheets correctly.

    My testing is always the same.

    1. Enable macros and open generator
    2. Click on reset button.
    3. Enter client details
    4. Click on Save button to generate new job sheet.
    5. Disable macros in Excel
    6. Exit Excel
    7. Open the new job sheet.

    So I don't know if this in an intermittent bug or if there is something prone to errors in one of the macros or if it's a 'problem' in Excel like a service still running when Excel is shut down that means the settings Trust Centre Settings aren't quite updated.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: One Macro Breaking Another

    I don't know what the problem is. The only other thing I can think of is when you close the generated sheet, the sheets are not getting hidden by the Workbook_BeforeClose code. I don't know why that would happen though. As a diagnostic test, you may want to put a message box at the end of the Workbook_BeforeClose code so you can see that code has been run.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Breaking-up the contents of a cell with a macro
    By simonfoster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2009, 11:58 AM
  2. How do I run a macro w/o breaking cell ref's?
    By gshock in forum Excel General
    Replies: 4
    Last Post: 12-02-2008, 02:06 PM
  3. Macro - Breaking Number Ranges
    By rfarrell in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-01-2008, 02:27 PM
  4. Breaking links in a macro
    By Tim G. in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2006, 09:35 AM
  5. [SOLVED] problem breaking macro into 2 subroutines
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2006, 03:25 PM
  6. [SOLVED] breaking during a macro run
    By maxzsim in forum Excel General
    Replies: 1
    Last Post: 03-09-2006, 03:55 AM
  7. Breaking links using a macro
    By Smithochris in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2005, 04:24 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1