How to open a book with parameters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have to open a book from another one and to pass to it somehow the value of
a variable. Is it possible with VBA?

Thanks for helping me
 
Hi Daniel

To opem the secod workbook, run a pprocedure in the second workkbook and
pass it a parametric value, try somethinh like:

'============>>
Public Sub Tester()
Application.Run "'OtherBook.xls'!Demo", "Hello"
End Sub
'<<============

Where the second workbook has a procedure like:

'=============>>
Public Sub Demo(sStr As String)
MsgBox sStr
End Sub
'<<=============

Running the procedure Tester in the first workbook,
the second workbook will be opened (if it is closed)
and its Demo procedure will run and will report the
value of the passed parameter - in this case the string
"Hello".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top