spences10 / VBA-IDE-Code-Export

Export & Import VBA code for use with Git (or any VCS)
MIT License
119 stars 34 forks source link

Deletion of macros' components after export of code #78

Closed TheWirtschaftsmann closed 7 years ago

TheWirtschaftsmann commented 7 years ago

Hi @spences10 ,

I'm trying to experiment with code export functionality and I'm facing some strange behavior. I've created a test macro with simple user form. I've generated a config file and exported the code. As it seems the code is intact, however when I check my Excel file afterwards, all macro components (i.e. form, module) were deleted. Is that intended behavior or I missed something?

image

spences10 commented 7 years ago

Yes my friend that is intentional

The idea is that the code is exported for use in a VCS system like GitHub

You can import the code again once you have exported it 👍

If you look in the folder where the Workbook vbaGIT.xlsm is located you should see the exported files 🤓

TheWirtschaftsmann commented 7 years ago

Yes, when I take a look in the folder, all source files are right there. But what I do not understand why is it needed to delete them from Excel book? That's what I want to know as well as if it would be possible to change that. It seems like an extra and IMHO a bit annoying step (or maybe I'm just a bit too lazy:).

Let's suppose I have a macro - I've did some modifications, pressed Export button. It generated source files, which I commit / push to GitHub. After these steps I have an updated version on GitHub and in Excel immediately without need to import the code. This procedure looks a bit simpler.

mattpalermo commented 7 years ago

If I may add to @spences10's explaination:

After these steps I have an updated version on GitHub and in Excel immediately without need to import the code.

If you intend to commit both the exported VBA code and the Excel file to a version control system like github, it works best if information is not duplicated. Firstly, just imagine the pain of making sure it is always in sync! Secondly, think about what having the VBA code stored in text format affords you. With VBA stored as text, you can merge different versions of the VBA code using git. @spences10 and I do this all the time. But Git cannot help you with merging the Excel file. If the VBA code was stored in the Excel file, you're going to loose this advantage.

That's what I want to know as well as if it would be possible to change that. It seems like an extra and IMHO a bit annoying step (or maybe I'm just a bit too lazy:).

It wouldn't be difficult to separate the "export & clean" action into an "export" and "clean" action. In fact, we already need to do this internally to finish the work on issue #30. I think this may help users who may want to export unfinished work and stage it to Git's staging area, but they want to keep working on it. And I'm sure there would be more valid use cases for it. What do you think @spences10? Just need to make sure users understand the benefits of doing the "clean" before committing the Excel file.

spences10 commented 7 years ago

Hi @TheWirtschaftsmann,

Has your question been answered here?

I think @mattpalermo has done a champion job of explaining this. :+1:

TL;DR

The code is extracted out of the workbook so that the code isn't duplicated.

The idea being that the workbook and the code are stored on a VCS


@mattpalermo I think #30 is a valid piece of work that needs to be done to reduce any data loss, #78 however could be done but I feel that it's adding needless complexity to the process.

You want to export the code, export the code, you want to import the code import the code, I don't think there should be any more steps here.

If you want to carry on working on the code that you have just exported then just import the code again... right?

TheWirtschaftsmann commented 7 years ago

Hi @spences10 , hi @mattpalermo ,

Thanks for explanations. It seems reasonable.

P.S. I've also tried to import back the source code into Excel, but for the moment, I cannot succeed with that. I'll tried a bit later again and if I won't be able to do it again, I'll open another issue with additional questions:)

spences10 commented 7 years ago

@TheWirtschaftsmann ah, well that is a problem

Taking a look at your repo it looks like one of the modules are not listed in the CodeExport.config.json file, looks like modTesting.bas is not in there is that the module that is missing or where you are having issues?

Can I ask, as well, did you compile the add-in from source or just download it from releases