1.

Solve : (VB 6.0) Auto-execute via Combo Box Selection?

Answer»

Can anyone help me... I NEED to ensure whenever I select a Combo Box Option, it will run the respective command.

This is for Visual Studio 6.0. Thanks in advance.Try using the SHELL function:

Code: [Select]dim rc as INTEGER
rc = shell("notepad.exe")

Note: if it's a batch command, you need to include the command PROCESSOR in the shell function:

Code: [Select]dim rc as integer
rc = shell("cmd /c copy fileA fileB")

Happy programming. 8-)Thank you! But how do i integrate it into my code... i know Combo Box options can be identified by integer as well.

Quote

Private Sub Combo3_Change()

xlDoc = cbx_DailyRep.Text

Set xlApp = New Excel.Application

Set xlBook = xlApp.Workbooks.OPEN("d:\oss\" & xlDoc & ".xls")

xlApp.Visible = True

Set xlBook = Nothing
Set xlApp = Nothing

End Sub

In here, how do i encode it so that a specific excel document will open when i choose the option from the combo box? Is it possible or is there something i'm missing out on?Quote
I need to ensure whenever I select a Combo Box Option, it will run the respective command

Misread read your question to imply an external command. What was I thinking :-?

This should work:

Code: [Select]Private Sub Combo3_Change()
xlDoc = cbx_DailyRep.Text
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open("d:\oss\" & [highlight]combo3.seltext[/highlight] & ".xls")
xlApp.Visible = True
Set xlBook = Nothing
Set xlApp = Nothing
End Sub

Naturally all the choices in the list need to be Excel workbooks.

8-)sry for the tardy reply, but thanks for your help


Discussion

No Comment Found