+ Reply to Thread
Results 1 to 5 of 5

Save/Embed arrays in an addin

  1. #1
    Forum Contributor
    Join Date
    06-22-2011
    Location
    somerset
    MS-Off Ver
    365
    Posts
    328

    Question Save/Embed arrays in an addin

    So for single variables if I want to save it in VBA I just create a constant.
    Is there something I can do to save an array or list in the document without making them populate cells?
    It's only a few hundred items so I don't want to put it in a hidden worksheet or the file size will be bulked up and I will have to draw from it each time which is wasteful.
    I was thinking maybe an XML file in the xlsb but I am not very good with markup languages.
    Sub Reputation()
    Dim Problem as Variant
    Dim Reputation as Integer
    For Each Problem in Forum.Threads
        If Problem.Title = "*[Solved]*" and Solver.Name = "Leon V (AW)" Then Reputation = Reputation + 1
    Next Problem
    End Sub

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Save/Embed arrays in an addin

    There are number of ways.
    1. Store it in external text file and read from it upon workbook open event. Or some other trigger.
    2. You could hard code it in VBA. But I don't see any benefit from it.
    Ex:
    Please Login or Register  to view this content.
    There are other methods, but this will depend on your specific preference and need.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Forum Contributor
    Join Date
    06-22-2011
    Location
    somerset
    MS-Off Ver
    365
    Posts
    328

    Re: Save/Embed arrays in an addin

    The text file is essentially what I am looking for in XML the focus being it can be stashed inside the .xlam.zip rather than a separate file that has to be kept with it. It is for what functions users have access to so it can't just be a text file in the open that anyone can edit.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Save/Embed arrays in an addin

    There are several ways.

    Host text file in cloud for consumption by the code. Or just go with my 2nd suggestion.
    Alternately, host the file in shared folder designated as read only on network location (if every user is on same domain).

    There are other flavors, but same principle will hold, whichever method you wish to use.

  5. #5
    Registered User
    Join Date
    03-08-2016
    Location
    UK
    MS-Off Ver
    Windows 10
    Posts
    6

    Re: Save/Embed arrays in an addin

    You can store data in a "custom XML part" (google it). But it would be far simpler to use a hidden worksheet. Would that really take up a lot more size than XML, which is also bulky? I don't know the answer but I would try a worksheet first, and only resort to an alternative if I really needed to. If you're concerned about the time it takes to read from a worksheet, make sure you read the whole table into an array in a single VBA statement. I'd be surprised if that isn't fast enough. (And I'm not at all sure that reading from a file or XML part would be any quicker.)

    (I used a custom XML part recently, but only because it was Word, not Excel, so I didn't have the option of using a worksheet.)

+ 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] Before Save with Addin
    By kickme93 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2013, 09:11 AM
  2. [SOLVED] VBA - Save, and Embed in Email (Outlook)
    By jlo33 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 07-19-2013, 10:10 AM
  3. Macro to save shared addin to personal addin folder
    By MrStyx in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-31-2008, 10:13 AM
  4. Save addin in runtime
    By gabch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2006, 02:40 PM
  5. [SOLVED] Can an addin save variables or arrays to a workbook
    By John in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-28-2006, 08:40 AM
  6. Before Save w Addin
    By tjh in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-16-2005, 07:45 PM
  7. [SOLVED] How do I un-embed images in Excel and save them to another folder.
    By marcusgrimm in forum Excel General
    Replies: 1
    Last Post: 06-23-2005, 07:05 PM

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