VB Script in Ecell

D

Dennis Evans

Hi

I have 2 basic questions

1. I have an Excel file with a Form I created in VB. How do I get this from
to load automatically when the Speadsheet is open.

2. A VBscript that will open the above Form in Excel and bring it to the
forground from a 3rd part application

Cheers
 
B

Bob Phillips

Dennis Evans said:
Hi

I have 2 basic questions

1. I have an Excel file with a Form I created in VB. How do I get this from
to load automatically when the Speadsheet is open.

Private Sub Workbook_Open()
Userform1.Show
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code
2. A VBscript that will open the above Form in Excel and bring it to the
forground from a 3rd part application

You need automation for this. Something along the lines of

Dim xlWb As Object
Dim sFile As String

sFile = "C:\Documents And Settings\Bob\Desktop\Area Codes.xls"
Set xlWb = GetObject(sFile)
'do more stuff
xlWb.Close
Set xlWb = Nothing

which assumes that Excel is already running, and that you have the previous
userform display code in that workbook.
 
Top