+ Reply to Thread
Results 1 to 10 of 10

Disabled macros block VBA code

  1. #1
    Registered User
    Join Date
    12-31-2012
    Location
    Poland
    MS-Off Ver
    2016
    Posts
    58

    Disabled macros block VBA code

    Hi, I have a set of macro-enabled files that are updated each month. I have another, main file that takes data from those sheets and puts up its list. The VBA code of my main file goes like this:

    Please Login or Register  to view this content.
    Now, data is extracted from files that have the following VBA code preventing people from opening them unless they enable macros. It also blocks the VBA code in my main file, but I'd rather preserve that part so that people always enable macros.

    Please Login or Register  to view this content.
    Can I set up the VBA code in my main file so that it does one of two things:
    • enables macros in the other files;
    • saves the other files as .xlsx and takes data from those, later removes the files?
    Last edited by buhaj47; 08-16-2018 at 08:06 AM.

  2. #2
    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,908

    Re: Disabled macros block VBA code

    Why? I can't see that your code needs to run any macros in the other files.
    Rory

  3. #3
    Registered User
    Join Date
    12-31-2012
    Location
    Poland
    MS-Off Ver
    2016
    Posts
    58

    Re: Disabled macros block VBA code

    Still, I cannot run the macro that worked before the source files were macro-enabled. Now I get the following error message:

    Capture.JPG

    Capture2.JPG

  4. #4
    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,908

    Re: Disabled macros block VBA code

    Try changing that to:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-31-2012
    Location
    Poland
    MS-Off Ver
    2016
    Posts
    58

    Re: Disabled macros block VBA code

    That is better, yet another error message pops up:

    Capture.JPG

    Capture.JPG

    The sheet data is extracted from is password-protected. Cells with data in question are unlocked if it matters. Is there any way I can leave the protection in place and have the code work?
    Last edited by buhaj47; 08-17-2018 at 04:02 AM.

  6. #6
    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,908

    Re: Disabled macros block VBA code

    Which line causes that error?

  7. #7
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Disabled macros block VBA code

    Yes you may programmatically un-protect the sheet , run the code and then reprotect the sheet (programmatically).
    Last edited by ImranBhatti; 08-17-2018 at 03:59 AM.
    Teach me Excel VBA

  8. #8
    Registered User
    Join Date
    12-31-2012
    Location
    Poland
    MS-Off Ver
    2016
    Posts
    58

    Re: Disabled macros block VBA code

    OK, I have modified the VBA code in my main file:

    Please Login or Register  to view this content.
    Now I get the following message when I try to extract the data from source files:

    Capture.JPG

    ======================

    Capture 2.JPG

    Any ideas?

  9. #9
    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,908

    Re: Disabled macros block VBA code

    That suggests there isn't a sheet called Protection when the workbook opens.

  10. #10
    Registered User
    Join Date
    12-31-2012
    Location
    Poland
    MS-Off Ver
    2016
    Posts
    58

    Re: Disabled macros block VBA code

    I don't think so, when I open source files manually, "Protection" sheet is there until I enable macros.

    EDIT: No, you're right, I've copied and pasted source files once again and the code works!
    Last edited by buhaj47; 08-17-2018 at 06:00 AM.

+ 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. Replies: 0
    Last Post: 06-09-2015, 09:30 PM
  2. Macros have been disabled
    By Divakar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2013, 05:36 AM
  3. Macros enabled workbook keeps saying macros are disabled
    By joker3 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-15-2013, 11:28 PM
  4. Replies: 5
    Last Post: 07-26-2012, 09:38 PM
  5. Macros Disabled ?
    By khalid79m in forum Excel General
    Replies: 2
    Last Post: 02-21-2008, 10:57 AM
  6. [SOLVED] Macros are disabled
    By cgore in forum Excel General
    Replies: 1
    Last Post: 02-17-2006, 01:35 PM
  7. [SOLVED] Macros disabled
    By FJB in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-12-2005, 09:05 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