Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2016-10-05
4
Medium Priority
?
75 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 28

Accepted Solution

by:
MacroShadow earned 2000 total points
ID: 41830756
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
ID: 41830774
Awesome, thanks for the help!
0
 
LVL 28

Expert Comment

by:MacroShadow
ID: 41830784
Glad it worked :)
0
 
LVL 3

Author Comment

by:Jon DeVito
ID: 41830790
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

877 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