Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If I have two excel files (both with VBA applications) open and I am running
VBA application from one of them, when I try to do User1.show, it fails. I get a Run Time error 9. Subscript out of range. However if I close the application I am not using at the moment the User1.Show works as expected. Any help would be appreciated, Gary |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello Gary, When 2 or more Workbooks are open and running VBA it is important to use fully qualified object references. You can have 2 UserForm1 forms declared. You have to tell Excel which form you want by qualifying the reference with the workbook it belongs to. Example: Workbooks("Book1").UserForm1.Show Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=555233 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Leith,
Thanks for your response. It makes sense, but when I tried: myworkbook = ThisWorkbook.Name ' shows current workbook in debugger Workbook(myworkbook).UserForm1.show ' compile error ! I got "sub or Function not defiend error" Any ideas ? Gary "Leith Ross" wrote: Hello Gary, When 2 or more Workbooks are open and running VBA it is important to use fully qualified object references. You can have 2 UserForm1 forms declared. You have to tell Excel which form you want by qualifying the reference with the workbook it belongs to. Example: Workbooks("Book1").UserForm1.Show Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=555233 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() ello Gary, You need to use the SET statement to define your object reference... Dim MyWorkbook As Workbook Set MyWorkbook = ThisWorkbook Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=555233 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel VB - show userform1 (at same time) minimized application win | Excel Discussion (Misc queries) | |||
VBA + VB Script fails to open the workbook. | Excel Programming | |||
Workbook fails to open - Excel 2003 | Excel Discussion (Misc queries) | |||
Excel fails to open workbook using Automation from VB 6 | Excel Programming | |||
SetFocus to first textbox on userform upon Userform1.Show | Excel Programming |