Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
| Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 25th, 2006, 07:36 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default UserForm1.show fails if another workbook is open

If I have two excel files open and 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.

If I try to qualify the UserFrom1.Show with Workbook("Book1").UserFrom1.Show I get a compile error as "Sub or Function Not defined"

Any help would be appreciated,

Gary
 
Old June 26th, 2006, 01:23 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Is there something within the initialization within the code of the form itself that might be throwing this error?
 
Old June 26th, 2006, 06:37 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian,

Thanks for writing. I have fixed the problem by simply renaming UserForm1 to something else and changing references to it. The problem resulted from two VBA applications having the same form name.

gary

 
Old June 27th, 2006, 02:58 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

In this case, each VBA application has a project name. If you run into this again you can "fully qualify" the form names: Prj1.UserFrom1.Show, (etc.)

Glad you solved it.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Handling Non-Existing Web Files with Workbook.Open white_wulff Excel VBA 1 May 14th, 2007 03:07 PM
Excel 2003 VBA - Need to open a workbook in a fold bablhous BOOK: Excel 2003 VBA Programmer's Reference 0 December 21st, 2006 02:50 PM
Workbook Open anup.bihani Excel VBA 2 November 30th, 2006 01:05 AM
Error when open workbook gastoncs Excel VBA 2 December 21st, 2005 12:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.