Importing .bas files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to import a function stored in a .bas file into an Excel
file, without having to switch to the VBA code view and import it? I'm
looking for an easy way to teach end-users to do it.

Thanks for your help!
 
Build a button that runs the macro. You won't get away without code or going
top the VBE.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Joel said:
Is there a way to import a function stored in a .bas file into an Excel
file, without having to switch to the VBA code view and import it? I'm
looking for an easy way to teach end-users to do it.

Thanks for your help!

I'm not 1++% sure what you want. Do you want to view the file or do you want
to run the code?

/Fredrik
 
Fredrik Wahlgren said:
I'm not 1++% sure what you want. Do you want to view the file or do you want
to run the code?

/Fredrik

I have a VBA function that I built, and exported it to a .bas file. This
function can be used in many different spreadsheets by many people. If
someone has a spreadsheet, currently, they have to:

1. Right-click on the worksheet name tab.
2. Click View Code
3. Make sure Project Explorer is visible.
4. Right-click in Project Explorer, and click "Import File..."
5. Browse to the .bas file, and import it.

From there, it can be run from the Macro menu.

However, getting into the "View Code" window can be an intimidating (and
dangerous) place for end-users. I was wondering if there is a way to import
the .bas file, WITHOUT needing to switch to the "View Code" view? Can it be
done from the normal Excel user interface somewhere?
 
Joel,


You can import a bas file programmatically with code like the
following:

ThisWorkbook.VBProject.VBComponents.Import _
Filename:="H:\Module1.bas"

For this to work, Excel must have trusted access to the
VBProject. Go to the Tools menu, choose Options, then Security.
On the Trusted Sources tab, check the "Trust Access To VBProject"
setting.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Back
Top