Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

828 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