General discussion

Locked

VB6 abd Excel97

By M.R.Chambers ·
I need/want to be able to control an Excel workbook from a VB6 app, like you can with an Access DB. I need to be able to input values to specific cells, activate macros (one of which imports data from Access and one that exports to Word)...all fromthe environment of my application. I have the Access part mostly sorted out, but was wondering about the Excel side.
Can anyone help?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

VB6 abd Excel97

by keith.hall1 In reply to VB6 abd Excel97

Select Tools, Reference and click on tickbox for Microsoft Excel 8.0 of your VB application to use an early binding reference to the Excel Application
Sample code:
Declare a refrence to the Excel application:
Private wks as Excel.Application
'Private wks As Object ' is the alternative for a Late Binding object

To start the excel app either use for early binding:
Set wks = New Excel.Application
'Set wks = CreateObject("Excel.Application")'late binding
'wks.Visible = True ' depends on whether you wish to see it

Opening a specific spreadsheet:
wks.Workbooks.Open Filename:="yourexcel.wks"

Placing a specific value in cell a1 on sheet1:
wks.Workbooks("yourexcel.wks").Worksheets("sheet1").Range("a1").Value = 1

Running a sub called hello in ThisWorkBook with a string parameter
wks.Run "yourexcel.wks!ThisWorkBook.hello", "Hello world"

Save the sheet
wks.Workbooks(SimName).SaveAs Filename:=SaveName

Collapse -

VB6 abd Excel97

by M.R.Chambers In reply to VB6 abd Excel97

Poster rated this answer

Collapse -

VB6 abd Excel97

by M.R.Chambers In reply to VB6 abd Excel97

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums