Import/Include VBA Code From File

dukquack

New member
Local time
Today, 17:52
Joined
Nov 9, 2012
Messages
6
Hi guys,

Sorry if this is a silly question, I am just wondering if there is a way to import/include vba code from a text file. If any of you come from a php background, you can include html/code using the include function, is there a similar way to do this in VBA?

Thank you in advance! :)
 
dukquack, I know what you mean, IMHO, you will not be able to load files unless the file you are loading is a Dynamic Link Library (a DLL file).. However you can use the Application.LoadFromText method to "import" the module into your Application..
 
Hi mate, thanks for your reply. I have tried that import from text file module thing, but I'm a bit unsure of how to do it. The code im trying to import is a microsoft class object tied to a form, as you can probably tell I am not the best at VBA and it's structure, do you know of any resources on the internet that would give me a walkthrough?

Thanks again mate
 
While putting up the reply, I was looking for some links that will have some documentation of LoadFromText.. Unfortunately there are not many available..

The general syntax would be..
Code:
Application.LoadFromText acForm, "Form_[COLOR=Blue][B]FormName[/B][/COLOR]", "[B][COLOR=Blue]PathToFile/FileName.txt[/COLOR][/B]"
Change all blue bits..
If you type Application.LoadFromText and hit space you will get a list of objects, like ac Form, acQuery, acModule etc... That should help.. Also this..
 

Users who are viewing this thread

Back
Top Bottom