View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Using or loading external code

Look at VBIDE.CodeModule.AddFromFile.
You will need a reference to the VBE extensibility library.
Bear in mind that after importing the code it will need a re-compile, so
all your variables will be reset and forms will need to be unloaded etc.

RBS

"GDCobra" wrote in message
...
Hi

I have a spreadsheet which uses a number of macros and forms to control
entering of data relating to a product. Each new product requires a new
instance of the spreadsheet so I open a 'Master' copy and then save with a
new name.
Creating copies in this way gives a problem if I edit any of the code or
form structure as I have to go back through each instance and import the
affected modules and forms previously exported from the MASTER.

So. is it possible to have my code loaded in separate file and access this
remotely from the spreadsheets?
OR
Create a macro in the spreadsheet which will delete all current modules
(apart from the one containing itselr) and froms then import the code from
an
external file? In other words automate the task I am having to do.