PDA

View Full Version : Solved: .bas vba export question



ukdane
10-21-2009, 03:43 AM
If I have created a Macro, and exported it as a .bas file, is it possible to run the code directly from the .bas file?

The code is used to create a csv file based on an excel workbook received from a customer. (We can't get the customer to include the vba directly into their workbook).

p45cal
10-21-2009, 04:32 AM
What is your aim here?
Do you want the vba in the workbook so that the customer runs it and just sends you the csv file?
Do you want to run the vba after you've got the workbook from the customer? (put it in personal.xls)

ukdane
10-21-2009, 04:41 AM
I want to open the workbook from the customer, and press a button on my toolbar which will open/run bas macro (which in turn generates the .csv)

p45cal
10-21-2009, 04:49 AM
put the macro in Personal.xls (when you record a macro you get the choice of where the code goes. Record any simple macro (select a cell or two) then go to edit it via the dropdown menus to locate where you should paste the code.)

ukdane
10-21-2009, 05:07 AM
Sorry P45cal, I haven't explained very well.

I know how to import the code from the .bas file


The problem is that it isn't me that receives the files.

The person that receives them, and runs the macro isn't "pc" minded.

The only thing they should have to do is press the button to run the macro when they open the file from their customer, and that will generate the csv for them.

So I want the code to be imported /and run automatically when the user presses the button on the toolbar.


I've included a word doc, which has an image in which I try to explain what shoud happen.

Bob Phillips
10-21-2009, 05:23 AM
If the macro name is consistent, use APplication run with Activeworkbook.name strung with the macro name.

But why not put the macro in an addin, and stop relicating it all over?

Aflatoon
10-21-2009, 05:24 AM
Put the code into an add-in and distribute it to your user(s). (I'd suggest adding some code to the add-in to create a menu)
You can't have a button to import code without that button having some code to run... :)
(to answer your initial question, no you can't simply run a .bas file)

ukdane
10-21-2009, 11:44 PM
Great answer guys.
How do I create an add-in?

Bob Phillips
10-22-2009, 12:45 AM
See http://www.fontstuff.com/vba/vbatut03.htm

Aflatoon
10-22-2009, 12:49 AM
If you would like the add-in to have its own toolbars, you may wish to read this article (http://www.jkp-ads.com/Articles/DistributeMacro04.asp).