+ Reply to Thread
Results 1 to 5 of 5

Code to save XLA file

  1. #1
    Registered User
    Join Date
    07-27-2011
    Location
    Düsseldorf, Germany
    MS-Off Ver
    Excel 2007
    Posts
    2

    Code to save XLA file

    Hi,

    does anyone know the CODE to "automatically" save the XLA file that holds the code of a userform which the user is just busy with? I'd like to have the settings saved that the user has made in e.g. comboboxes? In other words, I am trying to avoid that the userform falls back to the original default settings, when called newly. In this example, the user can change the date format of a calendar (and other things) and it would be great if those settings are 'memorized', even after Excel has been closed and restarted.
    A solution would be a "Save Settings" button, provided I knew what code to put behind it
    The code would 'just' need to save the Add In, in other words, the XLA file.

    THANK YOU!!!

    Ben

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

    Re: Code to save XLA file

    You need to save the settings to a sheet within the addin. For example

    Please Login or Register  to view this content.
    Load the setting back with the Initialize event picking up from the relevant cells
    Hope that helps.

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

    Free DataBaseForm example

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Code to save XLA file

    Saving the add-in will not work unless your form reads and writes settings to a sheet in the add-in, since run time changes to userforms are not saved. A better bet in my opinion would be to save the settings in the registry using SaveSetting and GetSetting to read them back again when loading the form.
    Remember what the dormouse said
    Feed your head

  4. #4
    Registered User
    Join Date
    07-27-2011
    Location
    Düsseldorf, Germany
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Code to save XLA file

    @ roy, THANK YOU, this worked nicely! The ListIndex of a combobox is now stored in a cell of the Add In Sheet (and is read on initialize obviously).
    I have added this, not sure it's necessary:
    ThisWorkbook.IsAddin = True
    It takes 2-3 seconds to save the AddIn file (upon closing the userform; that's not exactly a long time but seems wrong when closing a form) so I wonder if romperstomper's idea about using the registry may be quicker.
    I probably just leave out the saving part and am happy that the settings are stored during the Excel session (haven't 'messed' with the registry ever before).
    Thanks once more to both of you!
    Ben

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

    Re: Code to save XLA file

    You don't need IsAddin if it's already saved as an addin.

    Registry is probably faster, I use it quite a bit. I just thought the save in worksheet would be easier and because an addin is basically an invisible workbook it would be secure

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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