hilkoc / vbaDeveloper

Tools for development and version control of vba code
MIT License
516 stars 137 forks source link

Installation Issue #19

Open lysakowski opened 8 years ago

lysakowski commented 8 years ago

This looks like a great tool but I am unable to get it to work. I followed the instructions exactly, including setting the correct reference to "Microsoft VBA for Applications Extensibility 5.3" and the Microsoft Scripting DLL. I get an error message "Compile error: User-defined type not defined" and then the code stops and the debugger points to the first line in the first routine:

Public componentsToImport As Dictionary 'Key = componentName, Value = ComponentFilePath"

When I checked to see if the reference to "Microsoft VBA for Applications Extensibility 5.3" is set properly, the first time it was not. This extensibility DLL was not selected after reopening the Excel file after the build. So I selected it a second time, closed the workbook, and reopened the vbaDeveloper.xlam file by double-clicking on it. Then I verified whether the reference to "Microsoft VBA for Applications Extensibility 5.3" was set now and it is checked now.

After this, when I put the cursor into the testImport() procedure and hit the F5 button, I get a dialog box that allows me to select "importComponents" or "importCode" or "exportCode". When I select ImportComponents, I get the same error message as above... "Compile error: User-defined type not defined".

When I do "File.SaveAs..." on the workbook "Book1.xls" after reference has been set and the Build.bas code has been imported, it opens a dialog box pointing to the following directory

C:\Users\admin\AppData\Roaming\Microsoft\AddIns

At this point we are told to navigate to the * src/ directory and replace the filename "Book1.xls with the name "vbaDeveloper.xlam" and change the file type to "Excel Add-in (*.xlam)", and then save it.

When I do that Windows Explorer opens the pre-existing directory named ".\src\vbaDeveloper.xlam" (It opens that directory because that one is named exactly the same as the file to be saved in the .\src directory. In my case, there is an existing file "vbaDeveloper.xlam" from the previous attempt at doing the installation, so I simply replace it. I assume that this is what's supposed to happen.

I am relatively new to building other people's projects in VBA, so I don't know what is wrong. I suspect it could be an issue with the path to unzip the source code kit, because the Public variable "componentsToImport" isn't set correctly. However, I am guessing here based on the later code that references this variable. The instructions do not specify the preferred location to unzip the source code kit. Does this matter?

Is the source kit supposed to be in the root directory of the C drive or something? I have it in a Dropbox folder.

I assume we also need to finally enable the vbaDeveloper.xlam as an Excel Addin? There are no instructions to do that, but this step is obviously needed. When I do that, I don't get any menus in the Ribbon. I see a mention of menus in the code, but none appear in the Addins Ribbon.

Could someone please include some test criteria to let people know when the installation is successful?

I need help to install and use this. I am weary of copying VBA code from old workbooks, saving and versioning workbook filenames, etc. I can use the Personal.xlsb workbook approach, but real version control from within VBE would be much better. Specifically version control to create code libraries and check-in and check-out modules and functions for use in the current workbook, or at least load them as a group into new workbooks. A few more instructions how to use this tool with GitHub or SVN would be much appreciated.

jbridge8133 commented 8 years ago

@lysakowski
Hello, I am also a new user of VBA/Excel and using this Add-In. I also ran across the error "Compile error: User-defined type not defined". This was because I had not selected (or it hadn't kept) the Tools->References "Microsoft Visual Basic for Applications Extensibility 5.3" checked.

I have also noticed that after changing any settings in VBA or Excel I must save before exiting, otherwise settings may not be saved. I have had this problem more than once. So after checking the Extensibility is selected, Save. Then try hitting F5 with cursor in testImport function.

Also after the Extensibility option was selected, I did not get that popup asking which macro I wanted to run. It just ran, then a pause, then the left pane Project file view was populated below Build with ErrorHandling, Formatter, Menu..."

Hope that helps a little. Jenny

billelev commented 8 years ago

@lysakowski you said

At this point we are told to navigate to the * src/ directory and replace the filename "Book1.xls with the name "vbaDeveloper.xlam" and change the file type to "Excel Add-in (*.xlam)", and then save it.

which is what I was initially doing. The add-in file should be saved in the directory that src/ is in, not in the src/ directory.

So your hierarchy should be:

Also, when saving the add-in, if you select the file extension via the "Save as type:" drop down, then you will be redirected to the Windows AddIns directory. To prevent this, just type the full file name in the "File name:" prompt i.e. vbaDeveloper.xlam, and leave the save as type drop down.

lysakowski commented 8 years ago

Hi Bill and Jenny,

Thank you for your assistance. I finally got it to compile and import the build.vb components and xlam file correctly. At least now the debugger is not stopping it all the time. I get the following lines below.

"Invoking 'Build.importComponents'with Application.Ontime with delay 00:00:03
 almost finished importing code for vbaDeveloper
 Finished importing code for vbaDeveloper.   
 componentsToImport' was not initialized"

At the risk of showing my newness to VBA file handling and github, how do I set up my project folder(s) and vba modules so the code is imported and exported automatically in and out of github for each Excel VBA project? I want to organize them as libraries of subroutines and functions in folders in github, and then easily pull them into new Excel projects or push out the VBA subroutines and functions from Excel workbooks into my libraries. Right now I have all of my VBA modules in PERSONAL.XLSB, which very cumbersome because it opens up all modules in PERSONAL.XLSB everytime I open a new workbook. Any tips or tricks or explanation about use will be much appreciated, because I am building up a considerable number of versions of the same routines.

Thanks.

Rich

lysakowski commented 8 years ago

It appears to be working but I never see all of the modules imported into the VBADeveloper project itself, and no menus ever appear on the Ribbon Add-in menu, so I suspect it is not really working.

Here's what I get no matter how many times I run it:

"Invoking 'Build.importComponents'with Application.Ontime with delay 00:00:03 almost finished importing code for vbaDeveloper Finished importing code for vbaDeveloper componentsToImport' was not initialized."

Any hints or suggestions for using it from this point?

Thank you.

lysakowski commented 8 years ago

Okay it is working but it is exporting files to a directory and I don't know how to change destination directory. Similarly I can't see where to export functions and routines and modules from existing workbooks. Where do I change the file path to where files should be exported and imported?

Thank you in advance.

wrgrant commented 8 years ago

It looks like you can change where the files are exported in the method getSourceDir() within the Build module.

The line is: srcDir = projDir & "src\"

Change src\ to whatever you want.