This repository was archived by the owner on Sep 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See issue #4 and #5. This commit presents a solution which I think is simple and appropriate. #4 #5 The screenshot was removed because it is no longer relavent. Perhaps @spences10 can make a new one :)
I hope these instructions are clear
To make development easier, I set up a template Excel file. This Excel file is blank and has references to the nessesary libraries set already. To build the Add-in, open the template file and then import the files listed in the CodeExportFileList.conf (perhaps using a version of this tool already installed). Note that I have had to leave an empty module in the template file because Excel will delete the library references without it. This may be a problem to address with this tool.
My own decision bite me faster than I expected. I decided to add the template file to the gitignore file so that people wouldn't accedientally commit changes to it. Turns out that loosing work is worse then commiting mistakes.
The project was being renamed in the MakeFileList method. This was for historical reasons which now don't apply. The project name should be set at build time, not at run time.
If the Add-In is password protected it can't be accidentally edited in the VBE. This will keep you sain.
The project name was left as the default. This resulted in the built add-in having the default project name. This change fixes that.
The rubberduck VBA IDE code inspection tool shows possible problems with VBA code. Using this a few bits of the code was improved. * Accessors (Public / Private) were explicitly stated. * Procedure parameters / arguments "pass by" types were explicitly stated. * The use of the Is keyword was removed as it will most likely confuse others. * Some unused variables and procedures were removed. * Short variable names were replaced with more descriptive names I tried to apply a consistent code style based on the existing code style.
Previously, the format used for the config file was a simple list of key-value pairs which was represented in a text file using line breaks and colons. Additionally, square brackets had special meaning as well. Even for this simple serialization requirement, there was already a lot that the developer has to think about. For example there was a function which cleaned out strings to make sure the didn't break the serialization. A feature which will be implemented soon would be a lot easier to do if the config file was in a format such as JSON. Since JSON is fairly easy to read and write it seems like it doesn't introduce complexity. There is a popular open source VBA library for reading and writing JSON called VBA-JSON. I used this library and this simplified the data serialization code dramatically. I changed a few details of how the actual importing and exporting works, however there should be no loss of functionality. Relative and absolute file paths should now be supported, however I have not tested this yet. I have only tested the case where all files are in the base directory.
Library references (for example to the extensibility library) are removed from an Excel file if the file is saved with no VBA code in it. This may happen when using this add-in since all of the VBA code is probably going to be exported before save. To solve this, the add-in can now automatically inject references to libraries when the user calls the import action. The details of the libraries are declared in the configuration file. When the configuration file is automatically generated, it will read the library references which are currently referenced and list all the appropriate details in the configuration file. The "References" property of the configuration file is to be an array of objects. Each object represents a library reference with the following properties: * Name - name of the library * Description (optional) - description of the library * GUID - the GUID of the library * Major - the major version number of the library * Minor - the minor version number of the library * Path - The path to the library on the file system If the GUID property is given then the GUID, Major and Minor properties are used to locate the library, otherwise the Path property is used.
Add the required references to the configuration file and remove Module1 from the template binary.
Since the add-in now deals with more than just code, it also does references, some naming needs to be changed to reflect that.
This has the same issues as #10 😢 |
@Spence10 was having trouble importing the Dictionary.cls. The VBA-Dictionary project has encountered this same problem before and concluded that the problem was due to having Unix style line endings in the VBA source files (especially class modules). Firstly, a git attributes file was set up to make sure that VBA modules are converted to windows style line endings. Secondly, the use of the drop in Dictionary replacement is so that Excel for Mac is supported. However, the Microsoft scripting library is already used for file system purposes and therefore Mac isn't supported anyway. So there should be no loss of compatibility by using the Microsoft scripting library instead of the Dictionary drop in replacement. The Dictionary class was removed.
Merge fix for problem with importing the Dictionary class.
Ok, as with the json branch, I think this problem should be resolved now. |
No still not able to import the class, I tried drag and drop and the manual process same with #10 |
Sorry clicked wrong button 😕 |
Great work @mattpalermo 👍 * 1000 👌 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch (references) is based upon my json branch since it requires the json format for specifying references in the configuration file.
Library references (for example to the extensibility library) are
removed from an Excel file if the file is saved with no VBA code
in it. This may happen when using this add-in since all of the VBA
code is probably going to be exported before save. To solve this,
the add-in can now automatically inject references to libraries
when the user calls the import action. The details of the libraries
are declared in the configuration file. When the configuration
file is automatically generated, it will read the library references
which are currently referenced and list all the appropriate details
in the configuration file.
The "References" property of the configuration file is to be an
array of objects. Each object represents a library reference with
the following properties:
If the GUID property is given then the GUID, Major and Minor
properties are used to locate the library, otherwise the Path
property is used.
Sorry about a slightly messy diff. I also did a small amount of refactoring on the functions I was working on.