+ Reply to Thread
Results 1 to 8 of 8

Saving a visual basic (myfunc)

  1. #1
    Registered User
    Join Date
    12-15-2011
    Location
    TORONTO, CANADA
    MS-Off Ver
    Excel 2007-2010
    Posts
    9

    Smile Saving a visual basic (myfunc)

    i generated a new module in visual basic... (i'm new at this by the way)

    my question is: what kind of setting do i have to establish to make sure that 'myfunc' will save in the workbook after closing?

    micro settings? trust access to the VBA project object model? file block settings?

    THANK YOU
    Last edited by ConneXionLost; 12-16-2011 at 12:04 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Saving a visual basic (myfunc)

    Save it as an xlsm file.

    When you save as an xlsx, it strips any VBA project. And xlxs extension is a promise that the file does not contain macros.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Saving a visual basic (myfunc)

    You would save the file as a .xls or .xlsm file. A .xlsx file will remove any macros/modules upon saving it as that file type.
    Unless you're using add-ins, you would set macro settings to at least prompt you to run them, or to be allowed without prompting. If you personally trust where the macros are coming from, you can check Trust access to the VBA project object model, otherwise I would leave that unchecked.

    Note that if you are getting macros or VBA code from untrusted sources (like, say, random places on the internet), you would probably not want to trust all of it. VBA can be used to affect files and folders on your computer that are not limited to Excel or even microsoft office files. VBA can be used to change both Windows and registry settings. This is not to scare you away, just to inform you of what blindly trusting all code could cause.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Registered User
    Join Date
    12-15-2011
    Location
    TORONTO, CANADA
    MS-Off Ver
    Excel 2007-2010
    Posts
    9

    Re: Saving a visual basic (myfunc)

    thanks for that... i have now saved as 'xlsm' and i know i have a trusted code... should i be selecting 'enable all macros' and 'trust access to the VBA project object model' without worrying about anything?

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Saving a visual basic (myfunc)

    You should never, ever configure Excel to enable all macros.

    Set to Disable with notification.
    Last edited by shg; 12-15-2011 at 02:43 PM.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Saving a visual basic (myfunc)

    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Registered User
    Join Date
    12-15-2011
    Location
    TORONTO, CANADA
    MS-Off Ver
    Excel 2007-2010
    Posts
    9

    Re: Saving a visual basic (myfunc)

    i ended up not changing any options for macros,, and just simply made a trusted folder. thanks people

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Saving a visual basic (myfunc)

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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