vba scrpit

Jackeb

Board Regular
Joined
Mar 20, 2002
Messages
81
does anyone know how to (or wether or not it is possible) to create an object that opens the vba script in another excel file without opening the excel file itself?

Or how to extract the vba script from an excel file without opening the excel file??

cheers

Ed
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi Ed
I don't know about getting the script from another Excel file, but you can run code from a module which has been exported from another Excel file...
Comprende?
Tom
 
Upvote 0
how would you do this?

is it possible without opening the orrigional excel file?

Cheers
 
Upvote 0
On 2002-04-25 01:39, Jackeb wrote:
how would you do this?

is it possible without opening the orrigional excel file?

Cheers

AFAIK you have to open up the file.
I beleive there is code on this board to get the VBA code from an open file.
Do a seach.....
 
Upvote 0
Ed
You can import code on the fly via VBA without opening an Excel file. You can import the module alone without the overhead of opening another workbook. I posted an example of how to do this yesterday. Will try to find the thread...
Tom
 
Upvote 0
Here is an example...
Not as complicated as it looks, I'm just not real good at explaining...

Create a folder:
"C:/DynaLoad"

Open a new workbook, add a module,
rename the module "DynaMod"

Place the following procedure into
the module:

Sub LoadDynaTest()
Sheet1.Range("A1") = "Tis' Loaded!"
End Sub


Export the module into folder
"C:/DynaLoad"

Now remove the module from your
workbook all together.

Insert another module into this
workbook(name does not matter)

Place this sub in the module:

Sub CallDynaLoadedProcedure()
LoadDynaTest
End Sub


In whatever way you want to call it, call it:
The example here loads the module when the workbook opens.

Private Sub Workbook_Open()
Application.VBE.ActiveVBProject.VBComponents.Import "C:/DynaLoad/DynaMod.bas"
CallDynaLoadedProcedure
End Sub


You cannot call the procedure directly
until the bas file is loaded or you will get a compile error. That is why
we have the middleman procedure.
Save the workbook. Close it.
Open it. Check sheet1.Range("A1")
Your module is loaded into the project if the range has the data...

Tom
 
Upvote 0
On 2002-04-25 02:07, Jackeb wrote:
tom....

this is gonna save me... period

Ed

Ed sorry for putting you wrong I took your Q
literally to mean Getting a VBA module from
another work book....what Tom has proposed
is to actually just import code into your
book.....this of course can be done. The other way (getting code from another book)
will require the book to be OPEN.
 
Upvote 0
gotya, my solution requires a bit of both, the problem is that when I open the excel file it crashed on the open and automatically closes (COE3) so I cannot get to the vba script.... as tom says the only way appears to be to export the orrigional vba script......

this one is tricky

Ed
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,384
Members
448,956
Latest member
JPav

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top