Re: Run VBScript File by vb
You'll need to reference the "Microsoft Script Control" (Project -> References)
The use something like this. You will also need to put the code into a sub.
VB Code:
Private Sub Form_Load()
Dim CodeString As String
Open "code.txt" For Input As 1 'Input the file test.txt to the string CodeString
Do Until EOF(1)
Line Input #1, DataLine
CodeString = CodeString & Chr(13) & Chr(10) & DataLine
Loop
Close #1
Dim newSC As New ScriptControl 'Make a new ScriptControl
newSC.Language = "VBScript" ' Set the SC language to Visual Basic. Note that other languages such as JScript are also valid - check the help file associated with this command.
newSC.AddCode (CodeString) ' Add the code from the file to the SC
newSC.ExecuteStatement ("MySub") 'Run the code. Note it runs the statement "TestWindow" which is the name of the sub in the text file!
End Sub
In your file (code.txt)
Code:
Sub MySub()
Dim MyRef
Set myref=createobject("Photoshop.Application")
End Sub