1

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

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 4
    Not sure if I understand your question correctly, but have a look at how to use the [Microsoft Script Control](https://www.vbforums.com/showthread.php?510292-Execute-VB6-functions-from-a-textbox) 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](https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/shell-function) instead. – Hel O'Ween Sep 06 '21 at 16:19
  • 1
    The link does not work. Please copy and paste your code for the solution. – eglease Sep 10 '21 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 –  Mar 14 '22 at 18:55

2 Answers2

1

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.

eglease
  • 2,445
  • 11
  • 18
  • 28
  • but wscript is fine but i need to open internal forms in vbscript (form3.show) –  Sep 08 '21 at 12:30
  • 1
    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 (https://www.techotopia.com/index.php/Hiding_and_Showing_Forms_in_Visual_Basic)? – eglease Sep 08 '21 at 13:27
  • Did I understand it backwards and you want to open a VB6 program from VBScript? – eglease Sep 08 '21 at 13:28
  • Will this help https://stackoverflow.com/questions/67223096/reading-a-dll-or-vb6-file-from-vbscript? – eglease Sep 08 '21 at 13:34
  • 1
    #eglease no open vb6 in vbscript i need open vbscript in vb6 –  Sep 08 '21 at 13:55
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.

eglease
  • 2,445
  • 11
  • 18
  • 28
  • 1
    You easily can with Microsoft Script Control as noted earlier in a [comment](https://stackoverflow.com/questions/69058579/vb6-how-to-execute-vbs-i-add-form3-show-to-vbs-but-form3-come-from-vb6-project/69104326#comment122086916_69058579). Just give the script some object of yours, such as your `Forms` collection, with `AddObject`, and it then can operate on it. – GSerg Sep 08 '21 at 15:45
  • @GSerg This should be the answer. I am still not sure why you would want to do that but it does answer the question. – eglease Sep 08 '21 at 15:48