UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Pass Excel Worksheet To Other Function (late Binding), Access 2016    
 
   
MrSiezen
post Dec 1 2017, 03:07 AM
Post#1



Posts: 2,380
Joined: 15-February 05
From: Den Bosch - Netherlands


Hi!

I need to pass an already open excel sheet to as second function, but I don't know how...
I don't have references set to an Excel library, so I use late binding.

How do I pass it properly? Much appreciated!


CODE
Private Sub cmdCreateUppersPackinglist_Click()

sPath = "X:\Apps\ACCESS\blanco uppers packinglist.xlsx"
Set objBook = objApp.Workbooks.open(sPath)
'Set objApp = objBook.Parent
objApp.Visible = False
Set objSheet = objBook.Worksheets("packinglist")

With rs
    
    objSheet.Range("C2") = ![packlist]
    objSheet.Range("C3") = ![from_name]
    objSheet.Range("C4") = ![date_shipment]
    objSheet.Range("C5") = 0
    objSheet.Range("I3") = ![to_name]
    objSheet.Range("I4") = ![location_adress]
    objSheet.Range("I5") = ![location_zipcode] & " " & ![location_city] & " " & ![location_country]
  
iTeller = 7
SetExcelMatenbalk ![art_grading], objSheet, iTeller

etc...


CODE
Function SetExcelMatenbalk(gradation As String, ByVal objSheet As Worksheet, iRow As Long)


    'matenbalk vullen op basis gradatie
    If gradation = "EN" Then
        objSheet.Range("I" & iRow) = "3"
        objSheet.Range("J" & iRow) = "3H"
        objSheet.Range("K" & iRow) = "4"
        objSheet.Range("L" & iRow) = "4H"
        objSheet.Range("M" & iRow) = "5"

--------------------
UA Rulez!
Go to the top of the page
 
MrSiezen
post Dec 1 2017, 03:21 AM
Post#2



Posts: 2,380
Joined: 15-February 05
From: Den Bosch - Netherlands


Ah got it...

Need to pass it like this:
ByVal objSheet As Object

--------------------
UA Rulez!
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    10th December 2017 - 11:13 PM