Solved

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

Posted on 2016-10-05
4
31 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 27

Accepted Solution

by:
MacroShadow earned 500 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 27

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 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

17 Experts available now in Live!

Get 1:1 Help Now