ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to open a book with parameters (https://www.excelbanter.com/excel-programming/389098-how-open-book-parameters.html)

Daniel

How to open a book with parameters
 
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

Norman Jones

How to open a book with parameters
 
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".


---
Regards,
Norman


"Daniel" wrote in message
...
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




Daniel

How to open a book with parameters
 
Hi Norman:
Simple and clear. Great explanation. Thanks!

"Norman Jones" wrote:

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".


---
Regards,
Norman


"Daniel" wrote in message
...
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






All times are GMT +1. The time now is 02:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com