Consulting

Results 1 to 5 of 5

Thread: Solved: Reverse code on a macro

  1. #1
    VBAX Newbie
    Joined
    May 2008
    Posts
    2
    Location

    Unhappy Solved: Reverse code on a macro

    Hi fellas,

    I recently formatted my harddrive and have probably not installed VBA again, since I was unable to run macros on an Excel program I commonly use.

    I figured, since I hardly ever do anything with macros myself, I'd just search around for a code that "activates" the macros in the program I mentioned earlier. Knowing practically nothing about macros, I ran the code in this article (vbaexpress.com/kb/getarticle.php?kb_id=379) believing it would fix my problem. This wasn't the case since all worksheets disappeared, or hid

    Now I've understood that it's not possible to undo macros, so I'm kindly asking someone for a reverse code for this. Anyone, please?


    Best wishes from a cold Finland

  2. #2
    VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,005
    Location
    You must have at least one worksheet visible! it is this portion that hides the sheets:
    [VBA]Private Sub HideAllSheets()
    'Hide all worksheets except the macro welcome page
    Dim ws As Worksheet

    Worksheets(WelcomePage).Visible = xlSheetVisible

    For Each ws In ThisWorkbook.Worksheets
    If Not ws.Name = WelcomePage Then ws.Visible = xlSheetVeryHidden
    Next ws
    Worksheets(WelcomePage).Activate
    End Sub [/VBA]
    change it to:
    [VBA]
    Private Sub HideAllSheets()
    'Hide all worksheets except the macro welcome page
    Dim ws As Worksheet

    Worksheets(WelcomePage).Visible = xlSheetVisible

    For Each ws In ThisWorkbook.Worksheets
    If Not ws.Name = WelcomePage Then ws.Visible = true
    Next ws
    Worksheets(WelcomePage).Activate
    End Sub
    [/VBA]if you can change this in the workbook you ran it in you should be fine!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    VBAX Newbie
    Joined
    May 2008
    Posts
    2
    Location
    Thanks Simon, It worked!

    I read "this" and if the point means what I think it means, then no, this is the only place I've posted my question on. Can't see any reason for posting it on many places.

    Then a last question. I want the action that I was trying to do running the code (vbaexpress.com/kb/getarticle.php?kb_id=379) at the first time. I.e.g. activate my macros.

    So, as I press a macro that referres to another sheet in the workbook, I get this errorscreen: "Cannot run the macro "abc.xls'!def'. The macro may not be available in this workbook or all macros may be disabled." and then as I press "ok" I get error code 40040.

    I changed on microsoft>add or remove features>VBA for apps from install on first use to run from my computer, but this made no difference on my macros. Neither can I find anything like "enable macros" in excel (2007). If it could be of any use, I've changed names on the sheets after the macros were made (so "def" is actually named "ghi").


    Take care
    Robotek

  4. #4
    VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,005
    Location
    In xl2007 you have to purposely save a workbook as macro enabled! however i don't know too much about 2007 best you start a new thread with that in the thread title!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,074
    Location
    Hi Robotek, You can set your macro options in Excel 2007 by doing the following: Office Button/Excel Options/Trust Centre/Trust Centre Settings/Macro settings and select Disable all macros with notifications, then click OK.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

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