Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Convert config file to JSON format #10

Merged
merged 14 commits into from
Jan 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CRLF -> LF by default, but not for modules or classes (especially classes)
* text=auto
*.bas text eol=crlf
*.cls text eol=crlf
*.frm text eol=crlf
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Excel temporary files
~*
8 changes: 8 additions & 0 deletions CodeExportFileList.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Module Paths": {
"clsVBECmdHandler": "clsVBECmdHandler.cls",
"JsonConverter": "JsonConverter.bas",
"modImportExport": "modImportExport.bas",
"modMenu": "modMenu.bas"
}
}
1,134 changes: 1,134 additions & 0 deletions JsonConverter.bas

Large diffs are not rendered by default.

42 changes: 27 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,46 @@ For a while now I have used this code so that all the associated VBA files used

This is specifically for Excel, although the VBIDE extensibility can be used for all the MS Office suite.

## Description
On opening it will create a menu in the VBA IDE called 'Export for VCS' with the options 'Make File List', 'Import Files', 'Export Files' and 'Configure Export'.
## Installing

The default process for use is:
1. Obtain a copy of the add-in by following the build instructions below.
2. Save the add-in in your add-ins folder. Add-ins saved in your add-ins folder are loaded automatically.
3. Finally, enable the add-in in Excel.

1. Make a File List
- This will list all the objects in the project in a newly created module called 'modFileList'.
2. Export the Files
- This will export the files listed in 'modFileList' to the root folder of the current project and remove all but the 'modFileList' module from the project.
3. Import the files
- This uses the 'modFileList' module to build the project, all the files should be present to built the project.
## Usage

Additional functionality is there to configure a .conf file that will export the project contents to that instead of the 'modFileList' leaving your project completely empty. This can also be configured to set the import and export file locations.
The add-in will create a menu in the VBA IDE (the VBE) called `Export for VCS`. All controls for the add-in are found in this menu.

## Build
You will need to clone or download a zip of the project open an empty workbook in Excel then open the 'VBAIDECodeExport.xlam' add-in, you will be able to see the project from the VBA IDE [Alt+F11] pane of the new workbook you have just opened. The easiest way to do this is to drag and drop the components from file explorer to the VBA IDE
### The configuration file

![Import to IDE](https://raw.githubusercontent.com/spences10/VBA-IDE-Code-Export/master/screenshots/ImportFilesToVBAIDE.gif)
A file named `CodeExportFileList.conf` in the same directory as an Excel file declares what gets imported into that Excel file. The `Make File List` button in the `Export For VCS` menu will generate a new configuration file for the current active project based upon the contents of that project. Be careful; this command will overwrite any existing configuration file.

Save and open again, the auto_open should take care of creating the VBA IDE menu options and you're good to go
Standard JSON is used as the file format for the configuration file. The "Module Paths" property specifies a mapping of VBA modules to their location in the file system. File paths may be either relative or absolute. Relatives paths are relative to the directory of the configuration file and the Excel file. There are no other configuration properties *yet*.

### Importing

The `Import Files` button in the `Export For VCS` menu will import all the modules specified in the configuration file from the file system into the Excel file. Be careful; this command will overwrite existing modules in the active project.

### Exporting

The `Export Files` button in the `Export For VCS` menu will export all the modules specified in the configuration file from the Excel file into the appropriate places in the file system. Be careful; this command will overwrite existing files in the filesystem.

## Building

1. Open the template file `VBA-IDE-Code-Export.xlsm`.
2. Import the files specified in `CodeExportFileList.conf` (Tip: Use a previously installed copy of this Add-In).
3. Compile project as a smoke test.
4. Set password protection to prevent the Add-In code annoying you in the VBE and to prevent accidental changes.
5. Save as an Add-In.

## Contributing
Please fork this repository and contribute back using pull requests.

Any contributions, large or small, major features, bugfixes and integration tests are welcomed and appreciated but will be thoroughly reviewed and discussed.

Please use the template file `VBA-IDE-Code-Export.xlsm` for working in, however don't commit the template file unless you are actually making a change to the template file. This helps with source control since merging an Excel file is not fun.

## Roadmap

- [] Add pretty ribbon UI
- [] Save XL as XML

Binary file added VBA-IDE-Code-Export.xlsm
Binary file not shown.
Binary file removed VBAIDECodeExport.xlam
Binary file not shown.
11 changes: 7 additions & 4 deletions clsVBECmdHandler.cls
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'// Add reference for: Microsoft Visual Basic For Applications Extensibility 5.3

Option Explicit

'// Add references for :
'// Microsoft Visual Basic For Applications Extensibility 5.3

Public WithEvents EvtHandler As VBIDE.CommandBarEvents
Attribute EvtHandler.VB_VarHelpID = -1

Private Sub EvtHandler_Click(ByVal CommandBarControl As Object, Handled As Boolean, CancelDefault As Boolean)

Private Sub EvtHandler_Click(ByVal CommandBarControl As Object, ByRef Handled As Boolean, ByRef CancelDefault As Boolean)

On Error Resume Next

'// Run the code specified in the object's OnAction property.
Call CollectSettings
Application.Run CommandBarControl.OnAction

'// Indicate to the Events object that we've successfully handled the event.
Handled = True
CancelDefault = True

End Sub
77 changes: 0 additions & 77 deletions frmConfigure.frm

This file was deleted.

Binary file removed frmConfigure.frx
Binary file not shown.
Loading