ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calling procedure from another WKB with parameters (https://www.excelbanter.com/excel-programming/317126-calling-procedure-another-wkb-parameters.html)

Ajit

Calling procedure from another WKB with parameters
 
I have two wkb's say Book1.xls and book2.xls

from book1 I am calling a procedure(with arguments : Run
"book2.xls!test_msgbox(4,8)"


sub in book 2 is :
Sub test_msgbox(int_1 As Integer, int_2 As Integer)
int_1 = int_1 + 2
int_2 = int_2 + 3
MsgBox int_1 + int_2
End Sub

msgbox comes up twice. It comes up once with result 17 and after i hit OK it
is still there. Second time when i hit OK..msgbox closes.

But if i refer to a procedure without passing any values it works fine.

Any ideas what could be the reason. and how could it be rectified.

Thanks,
Ajit


--
Ajit

Bob Phillips[_6_]

Calling procedure from another WKB with parameters
 
Ajit,

Try calling like this

Application.Run "book2.xls!test_msgbox", 4, 8

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ajit" wrote in message
...
I have two wkb's say Book1.xls and book2.xls

from book1 I am calling a procedure(with arguments : Run
"book2.xls!test_msgbox(4,8)"


sub in book 2 is :
Sub test_msgbox(int_1 As Integer, int_2 As Integer)
int_1 = int_1 + 2
int_2 = int_2 + 3
MsgBox int_1 + int_2
End Sub

msgbox comes up twice. It comes up once with result 17 and after i hit OK

it
is still there. Second time when i hit OK..msgbox closes.

But if i refer to a procedure without passing any values it works fine.

Any ideas what could be the reason. and how could it be rectified.

Thanks,
Ajit


--
Ajit




Ajit

Calling procedure from another WKB with parameters
 
Bob,

It doesn't make any difference. Still msgbox is coming up twice.

"Bob Phillips" wrote:

Ajit,

Try calling like this

Application.Run "book2.xls!test_msgbox", 4, 8

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ajit" wrote in message
...
I have two wkb's say Book1.xls and book2.xls

from book1 I am calling a procedure(with arguments : Run
"book2.xls!test_msgbox(4,8)"


sub in book 2 is :
Sub test_msgbox(int_1 As Integer, int_2 As Integer)
int_1 = int_1 + 2
int_2 = int_2 + 3
MsgBox int_1 + int_2
End Sub

msgbox comes up twice. It comes up once with result 17 and after i hit OK

it
is still there. Second time when i hit OK..msgbox closes.

But if i refer to a procedure without passing any values it works fine.

Any ideas what could be the reason. and how could it be rectified.

Thanks,
Ajit


--
Ajit





Ajit

Calling procedure from another WKB with parameters
 
I am sorry i didn't looked at the syntax properly earlier. It worked fine.
Thanks!

"Bob Phillips" wrote:

Ajit,

Try calling like this

Application.Run "book2.xls!test_msgbox", 4, 8

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ajit" wrote in message
...
I have two wkb's say Book1.xls and book2.xls

from book1 I am calling a procedure(with arguments : Run
"book2.xls!test_msgbox(4,8)"


sub in book 2 is :
Sub test_msgbox(int_1 As Integer, int_2 As Integer)
int_1 = int_1 + 2
int_2 = int_2 + 3
MsgBox int_1 + int_2
End Sub

msgbox comes up twice. It comes up once with result 17 and after i hit OK

it
is still there. Second time when i hit OK..msgbox closes.

But if i refer to a procedure without passing any values it works fine.

Any ideas what could be the reason. and how could it be rectified.

Thanks,
Ajit


--
Ajit





Ajit

Another similar situation
 
Bob,

Your suggestion yesterday was very helpful. Thanks!

I am caught in another situation working with the same setup. Again i habe
two wkb's : Book1 & Book2. (Both have forms)

from book2.form1 i want to open book1.form1 and also want to make the
changes to listboxes in book1.form1 with respect to selections made in
book2.form1. (Code is written in Book2 i want to make changes with objects in
book1.form1)


if book2.form1.listbox1.value 20 then
book1.form1.listbox1.additem ("20")
else
book1.form1.listbox1.additem ("30")
end if


"Bob Phillips" wrote:

Ajit,

Try calling like this

Application.Run "book2.xls!test_msgbox", 4, 8

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ajit" wrote in message
...
I have two wkb's say Book1.xls and book2.xls

from book1 I am calling a procedure(with arguments : Run
"book2.xls!test_msgbox(4,8)"


sub in book 2 is :
Sub test_msgbox(int_1 As Integer, int_2 As Integer)
int_1 = int_1 + 2
int_2 = int_2 + 3
MsgBox int_1 + int_2
End Sub

msgbox comes up twice. It comes up once with result 17 and after i hit OK

it
is still there. Second time when i hit OK..msgbox closes.

But if i refer to a procedure without passing any values it works fine.

Any ideas what could be the reason. and how could it be rectified.

Thanks,
Ajit


--
Ajit





Bob Phillips[_6_]

Another similar situation
 
Ajit,

What you need to do is create a little procedure in the second workbook that
opens the form, and another that changes listboxes in that form, etc, and
then call that procedure from your first workbook as we discussed yesterday.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ajit" wrote in message
...
Bob,

Your suggestion yesterday was very helpful. Thanks!

I am caught in another situation working with the same setup. Again i habe
two wkb's : Book1 & Book2. (Both have forms)

from book2.form1 i want to open book1.form1 and also want to make the
changes to listboxes in book1.form1 with respect to selections made in
book2.form1. (Code is written in Book2 i want to make changes with objects

in
book1.form1)


if book2.form1.listbox1.value 20 then
book1.form1.listbox1.additem ("20")
else
book1.form1.listbox1.additem ("30")
end if


"Bob Phillips" wrote:

Ajit,

Try calling like this

Application.Run "book2.xls!test_msgbox", 4, 8

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ajit" wrote in message
...
I have two wkb's say Book1.xls and book2.xls

from book1 I am calling a procedure(with arguments : Run
"book2.xls!test_msgbox(4,8)"


sub in book 2 is :
Sub test_msgbox(int_1 As Integer, int_2 As Integer)
int_1 = int_1 + 2
int_2 = int_2 + 3
MsgBox int_1 + int_2
End Sub

msgbox comes up twice. It comes up once with result 17 and after i hit

OK
it
is still there. Second time when i hit OK..msgbox closes.

But if i refer to a procedure without passing any values it works

fine.

Any ideas what could be the reason. and how could it be rectified.

Thanks,
Ajit


--
Ajit








All times are GMT +1. The time now is 08:45 PM.

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