×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

passing Excel.Applications to VB6 subroutines

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/

Replies continue below

Recommended for you

RE: passing Excel.Applications to VB6 subroutines

Lift your skirt and show us your code.

RE: passing Excel.Applications to VB6 subroutines

(OP)
Hey THANKS Tick!

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

(OP)
But, but, but ...  I still can't do something like this,

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/

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close