passing Excel.Applications to VB6 subroutines
passing Excel.Applications to VB6 subroutines
(OP)
I'm trying to use early binding of an Excel.Application in VB6, then do some operations in subroutines, but references to the Application's properties when in the subs return nothing. I assume its a problem passing the application, byref, byvalue, as object, or by something into the subroutines that I don't understand. Anybody got any ideas on how2?
"Make everything as simple as possible, but not simpler." - Albert Einstein (1879-1955)
***************
http://virtualpipeline.spaces.live.com/
RE: passing Excel.Applications to VB6 subroutines
RE: passing Excel.Applications to VB6 subroutines
When I was writing this example code to show you... it worked! Before I was trying to pass XLApp. This time I tried just passing the worksheet XLWkSht.
If ExcelExists = False Then Exit Sub
Dim XLApp As Excel.Application
Dim XLWkBk As Excel.Workbook
Dim XLWkSht As Excel.Worksheet
If ExcelRuns = False Then _
Set XLApp = New Excel.Application
Set XLApp = GetObject(, "Excel.Application")
XLApp.Visible = True
Set XLWkBk = XLApp.Workbooks(WBindex)
XLApp.Workbooks(WBindex).Activate
Set XLWkSht = XLWkBk.Sheets(1)
XLWkBk.Sheets(1).Activate
WriteValues XLWkSht
End Sub
Public Sub WriteValues(XLWkSht)
XLWkSht.Cells(26, 2) = "FLOW"
XLWkSht.Cells(26, 3) = "HEAD"
XLWkSht.Cells(26, 4) = "EFF"
XLWkSht.Cells(26, 5) = "POWER"
End Sub
"Make everything as simple as possible, but not simpler." - Albert Einstein (1879-1955)
***************
http://virtualpipeline.spaces.live.com/
RE: passing Excel.Applications to VB6 subroutines
Public Sub Look4WkBk(XLApp, File_Name)
For i = 1 To XLApp.Workbooks.Count
If File_Name = _
XLApp.Workbooks(i).Path & "\" & _
XLApp.Workbooks(i).Name Then
XLApp.Workbooks(i).Activate
Exit For
End If
Next i
End Sub
"Make everything as simple as possible, but not simpler." - Albert Einstein (1879-1955)
***************
http://virtualpipeline.spaces.live.com/