Results 1 to 2 of 2

Thread: Run VBScript File by vb

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Run VBScript File by vb

    Hi All,
    I have herewith attached a vbs file which opens a photoshop. Now I want to open that file by vb code.Some body help please.
    I am not able to attach the file, I have placed the code here.

    Code:
    dim MyRef
    
    Set myref=createobject("Photoshop.Application")

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    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:
    1. Private Sub Form_Load()
    2. Dim CodeString As String
    3.  
    4.     Open "code.txt" For Input As 1 'Input the file test.txt to the string CodeString
    5.     Do Until EOF(1)
    6.       Line Input #1, DataLine
    7.       CodeString = CodeString & Chr(13) & Chr(10) & DataLine
    8.       Loop
    9.     Close #1
    10.    
    11.     Dim newSC As New ScriptControl 'Make a new ScriptControl
    12.     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.
    13.     newSC.AddCode (CodeString) ' Add the code from the file to the SC
    14.     newSC.ExecuteStatement ("MySub") 'Run the code. Note it runs the statement "TestWindow" which is the name of the sub in the text file!
    15.  
    16. End Sub
    In your file (code.txt)
    Code:
    Sub MySub()
    	Dim MyRef
    	Set myref=createobject("Photoshop.Application")
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width