Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using an excel command button to run VB script

Status
Not open for further replies.

alibongo

IS-IT--Management
Sep 6, 2001
29
GB
Hi,

I was wondering whether it is possible to run a VB script from an excel(97) command button or macro and if so how. I know excel 2000 has a script editor.

Perhaps the best way would be to have an excel macro open the html view and have a button to run my script from there, however, it would be nice to be able to run the script from within excel.

Thanks for your help, Alistair
 
What exactly do you wish to achieve with the script ?.

Do you have WSH (Windows Scripting Host) installed on your PC ? If not the following code should cause an error.
Code:
Dim oWsh
Set oWsh = CreateObject("WScript.shell")
If Not oWsh Is Nothing Then
    MsgBox "Windows Scripting Host installed "
End If
Set oWsh = Nothing
A.C
 
Thanks for the reply.

I don't have WSH installed, however, I have just contacted IT to sort it out.

I want the script to extract data from a text file in a specified file location, read each line and choose what I want and then import into my spreadsheet so I can analyse it.

I have heard it is also possible to import data to excel from another database using microsoft query or VB and settting the SQL query as .backgroundquery.

Any ideas about this would be appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top