+ Reply to Thread
Results 1 to 7 of 7

How to load VBA code on opening excel file.

  1. #1
    Registered User
    Join Date
    04-24-2013
    Location
    Holland
    MS-Off Ver
    Excel 2013
    Posts
    11

    How to load VBA code on opening excel file.

    Hi,

    I want the following code to be loaded automaticly when i open an excel file to prevent cells to be drag and dropped.
    Please Login or Register  to view this content.
    I have tried this with a clean sheet, but after closing and opening the file i could still "drag and drop" cells around.

    Anyone who can point me in the right direction?

    With best regards,

    Dinus.

    DragAndDropTest.xlsm

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441

    Re: How to load VBA code on opening excel file.

    your code needs to be in the Thisworkbook object not a standard code module.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    04-24-2013
    Location
    Holland
    MS-Off Ver
    Excel 2013
    Posts
    11

    Re: How to load VBA code on opening excel file.

    Thanks Andy,

    I have added it to the Thisworkbook code now (by Alt+F11, rightclick on 'ThisWorkbook, view code).

    However, when i open the workbook i still can move cells around unless i enable the macro content first (i get the 'Macro's have been disabled' note).

    Is there a way to solve this?

    Wbr,

    Dinus.
    Last edited by Dinus; 11-28-2013 at 10:16 AM. Reason: typo

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441

    Re: How to load VBA code on opening excel file.

    well yes if the macros are not enabled then you code will not run.

    you could hide all the sheets and only unhide them via code.

  5. #5
    Registered User
    Join Date
    04-24-2013
    Location
    Holland
    MS-Off Ver
    Excel 2013
    Posts
    11

    Re: How to load VBA code on opening excel file.

    Thanks Andy, that would work for me. Just to be sure, there is no way to auto enable macro's on startup?

    Wbr,

    Dinus.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441

    Re: How to load VBA code on opening excel file.

    Yes that is correct.

  7. #7
    Registered User
    Join Date
    04-24-2013
    Location
    Holland
    MS-Off Ver
    Excel 2013
    Posts
    11

    Re: How to load VBA code on opening excel file.

    Thanks Andy.

    /Solved

+ 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 in code - play music file automatically after opening file
    By mukeshbaviskar in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-15-2013, 10:06 AM
  2. [SOLVED] Code for opening file if match with file name is found
    By cokillerliu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2013, 08:41 PM
  3. Replies: 4
    Last Post: 01-24-2012, 12:52 PM
  4. Opening a browse and load file box in a macro
    By Scott Calkins via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-25-2005, 05:56 PM
  5. [SOLVED] Microsoft Excel tries to load front page on opening
    By Excel and Front Page in forum Excel General
    Replies: 1
    Last Post: 03-21-2005, 05:06 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