2

I found how to make this

Download_Example

I have a question about how to make execute VBS in vb6 (VBS haves form3 (from vb6 project .)show)

I made a dialog with Microsoft common dialog control 6.0

CommonDialog1.Filter = "File (*.vbs)|*.txt|All Files (*.*)|*.*"
CommonDialog1.DefaultExt = "vbs"
CommonDialog1.DialogTitle = "Select File"
CommonDialog1.ShowOpen

The FileName property gives you the variable you need to use

3
  • 4
    Not sure if I understand your question correctly, but have a look at how to use the Microsoft Script Control to execute VBScript code within your application, i.e. code in a textbox control. If you just want to execute the selected VBScript file as a separate process, use VB's Shell function instead. Commented Sep 6, 2021 at 16:19
  • 1
    The link does not work. Please copy and paste your code for the solution. Commented Sep 10, 2021 at 19:34
  • eglease im not him i found on internet, ask using the email on the 404 page and i put this years ago Commented Mar 14, 2022 at 18:55

2 Answers 2

2

A work-around might be just executing the script using Shell.

Shell "wscript.exe c:\myscript.vbs", vbNormalFocus 
Shell "wscript.exe " & CommonDialog1.FileName, vbNormalFocus 

See Microsoft's wscript documentation.

vbNormalFocus is there to restore focus to your vb6 program. It is optional but you probably want it. See documentation.

Sign up to request clarification or add additional context in comments.

5 Comments

but wscript is fine but i need to open internal forms in vbscript (form3.show)
Sorry, I am not sure I understand. You have a VB6 program and a VBScript, correct? You want to run the VBScript from your VB6 application, correct? By form, do you mean the VB6 dialog Form (techotopia.com/index.php/…)?
Did I understand it backwards and you want to open a VB6 program from VBScript?
#eglease no open vb6 in vbscript i need open vbscript in vb6
0

Looks like you are trying to run a VBScript from your VB6 app to open a dialog in the VB6 app.

VB6 -> VBScript -> Same VB6 

You cannot do this with Shell since it runs the script as a separate process. The Script does not know what Form3 is because it is a component of the VB6 app and would not exist as a separate entity once the app is compiled.

Edit: Looks like what you want to do is possible but with Microsoft Script Control. Here are a few examples. Thank you @GSerg for pointing this out.

This or this might be used as a work-around but I don't think it is the right way to go.

Go back to your requirements. What exactly are you trying to accomplish? There has to be a better way.

2 Comments

You easily can with Microsoft Script Control as noted earlier in a comment. Just give the script some object of yours, such as your Forms collection, with AddObject, and it then can operate on it.
@GSerg This should be the answer. I am still not sure why you would want to do that but it does answer the question.