Link to home
Start Free TrialLog in
Avatar of meniyk
meniyk

asked on

Excel VBA - How to call module procedure from Workbook Object after instanciated

Hi,
Is there a way to call and function module from the workbook object after instanciated based on the below scenerio...

The Book1.xlsm contain the macro that open up the Book2.xlsm and is set to workbook object.

e.g
Book1.xlsm
Module1

sub openfile()
      Dim wb as Workbooks.
      Set wb= Workbooks.Open("C:\test\Book2.xlsm",  ReadOnly:=True)
       wb.module1.test    '<-- how to call the procedure in his own module
       wb.module1.test1(wb) <-- how to call the procedure in his own module
End sub

*************

in Book2.xlsm
Module1

sub test1()
        msgbox ("Hi")

end sub

sub test2( wb as workbooks)
        bla bla bla...
       
end sub

Thank you.

best regards
YK
SOLUTION
Avatar of Faustulus
Faustulus
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Jacques Geday
Jacques Geday
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of meniyk
meniyk

ASKER

Thank you Faustulus, gowflow and andrewssd3.
Greatly appreciate you response and contribution.
That's amazing, Andrewssd3 manage to reslove my the problem and very well explain the concept. Once again Thank you Andrewssd3. Point has been mostly rewarded to Andrewssd3.
@andrewssd3
Great input. We never cease to learn it opens up new horizons. Tks again for your valuable input.

gowflow