LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Create and show UserForm from Add-In

Hi,

I have am running Excel 2002, and have written an Add-In (.xla).

Upon starting Excel, the add-in dynamically builds a menu. When the
user clicks one of the menu items, the add-in then dynamically creates
a user form (of type vbext_ct_MSForm), in the currently active
workbook. This form is then populated with controls (command buttons
and the like) and then tries to display it modally.

Because the add-in is protected, it can not be modified, so therefore
I have had to create the UserForm in the ActiveWorkbook. The problem
is that, once the form is created, I can not figure out how to show
it.

Refer to the sample code snippet below.

On line 13 I get the error "424 - Object Required". This is because
'MyCustomForm' was added to the ActiveWorkbook not the add-in's
workbook.

But, If I comment back in line 14, I get the compile error: "Method or
Data Member Not Found".

Can anyone help!

Thanks in advance.
Rick.

01 ' Create the form in the active workbook
02 Dim objForm As VBComponent
03 Set objForm = ActiveWorkbook.VBProject.VBComponents.Add(vbext_ct _MSForm)
04
05 ' Set the forms properties
06 objForm.Properties("Name") = "MyCustomForm"
07
08 ' Add controls to the form
09 ...
10
11 ' Add the user form to the UserForms collection
12 Dim myForm as Object
13 Set myForm = VBA.UserForms.Add("MyCustomForm")
14 'Set myForm = VBA.ActiveWorkbook.UserForms.Add("MyCustomForm")
15
16 ' Show the form
17 Call myForm.Show(vbModal)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Show UserForm if cell is emprty. Tdp Excel Discussion (Misc queries) 6 January 15th 09 02:56 PM
Userform won't show when file re-opened Gerry O Excel Discussion (Misc queries) 2 September 4th 07 05:42 PM
Properties window show nothing for a userform Cheer-Phil-ly Excel Discussion (Misc queries) 0 July 27th 06 07:15 PM
Userform.hide / show papou[_7_] Excel Programming 0 September 15th 03 03:12 PM
show a userform Joe[_17_] Excel Programming 0 July 18th 03 03:25 PM


All times are GMT +1. The time now is 08:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"