ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Importing .bas files (https://www.excelbanter.com/excel-programming/326029-importing-bas-files.html)

joel

Importing .bas files
 
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!

Bob Phillips[_6_]

Importing .bas files
 
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" wrote in message
...
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!




Fredrik Wahlgren

Importing .bas files
 

"Joel" wrote in message
...
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



joel

Importing .bas files
 


"Fredrik Wahlgren" wrote:


"Joel" wrote in message
...
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


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?

Chip Pearson

Importing .bas files
 
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





"Joel" wrote in message
...
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!





All times are GMT +1. The time now is 12:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com