Solved

VBS file using code from 2nd file (txt or vbs)

Posted on 2016-10-05
4
24 Views
Last Modified: 2016-10-05
Hi everyone, I need to include some code on hundreds of files so I would like to be able to keep a separate file that will hold all of the settings for these files so they can easily be changed at a later time.

If I take the contents exactly as is from the EMAILSETTINGS.VBS file & I paste them in the EMAILIT.VBS file everything works perfectly, but it wont use the code when I point to it as an included file. I've been able to pass the data as a variable into the main app & msgBox it, but I cant get EMAILIT.VBS to actually parse it as code.

Thanks in advance.
JD
EmailIt.vbs
EmailSettings.vbs
0
Comment
Question by:Jon DeVito
  • 2
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
MacroShadow earned 500 total points
Comment Utility
Please try this (not tested):
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile("EmailSettings.vbs")
Execute ts.ReadAll
ts.Close

Open in new window

0
 
LVL 3

Author Closing Comment

by:Jon DeVito
Comment Utility
Awesome, thanks for the help!
0
 
LVL 26

Expert Comment

by:MacroShadow
Comment Utility
Glad it worked :)
0
 
LVL 3

Author Comment

by:Jon DeVito
Comment Utility
I tried something very similar but I wasn't putting it all within the With section. I was putting the Set statements together at the top & the Execute within the With trying to keep it nice & clean but it didn't work. Thanks again for the help.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now