+ Reply to Thread
Results 1 to 5 of 5

Strange error in a workbook macro when a workbook unrelated is opened.

  1. #1
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Strange error in a workbook macro when a workbook unrelated is opened.

    So, I have the following code that show/hide a shape based on a cell value that works. But the problem is that if I open another workbook, unrelated to this one it throws a acccess denied error. Any ideas why?

    Please Login or Register  to view this content.
    Click the * to say thanks.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: Strange error in a workbook macro when a workbook unrelated is opened.

    I suspect it is because the Me is not fully qualified and relates to the new workbook/worksheet.

    Laptop is dead so I can't test the theory.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Strange error in a workbook macro when a workbook unrelated is opened.

    Me always refers to the object containing the code.

    Which line actually causes the error?
    Rory

  4. #4
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Strange error in a workbook macro when a workbook unrelated is opened.

    This line causes an error:
    Please Login or Register  to view this content.
    The strange thing is that it doesn't always returns an error. After some testing, I figured out that it returns an error only if I open a file with grouped sheets, even if is not related to the shapes workbook.

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Strange error in a workbook macro when a workbook unrelated is opened.

    That sounds like a bug to me.

+ 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. [SOLVED] error handler when no workbook opened
    By werevollf in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-23-2019, 10:09 AM
  2. [SOLVED] How to open another workbook from a separate workbook and run a macro on the one opened
    By bdouglas1011 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-17-2019, 02:18 AM
  3. Why can't i copy from an opened workbook without an error??
    By dbravo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2014, 12:28 PM
  4. Use a macro to extract cell data from opened workbook to new opened workbook
    By BrianTFC in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-26-2014, 01:35 PM
  5. UDF Function Returns Error when another workbook is opened.
    By beeblebrox82 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2013, 12:30 PM
  6. Replies: 0
    Last Post: 04-26-2013, 03:40 AM
  7. UDF gives #VALUE! error when workbook opened, but F2/Enter clears it
    By 6StringJazzer in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-03-2011, 04:18 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