PC Review


Reply
Thread Tools Rate Thread

delete userforms in vba

 
 
malpropio
Guest
Posts: n/a
 
      5th Mar 2007
Hey everyone,
I'm trying to get rid of a form I created in a project so I can
import another one which has the same name.
But so far I havent been able to find a way to do it.
So please let me know if thats possible and if not what would be the
solution to my problem.

Thx

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIEphY2tzb24=?=
Guest
Posts: n/a
 
      5th Mar 2007
In the code window, right-click on the user-form name in the left column and
select "Remove Userform".
--
Best wishes,

Jim


"malpropio" wrote:

> Hey everyone,
> I'm trying to get rid of a form I created in a project so I can
> import another one which has the same name.
> But so far I havent been able to find a way to do it.
> So please let me know if thats possible and if not what would be the
> solution to my problem.
>
> Thx
>
>

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      5th Mar 2007
in the project explorer in the VBE, right click on you userform entry under
the appropriate workbook and select remove.

--
Regards,
Tom Ogilvy


"malpropio" wrote:

> Hey everyone,
> I'm trying to get rid of a form I created in a project so I can
> import another one which has the same name.
> But so far I havent been able to find a way to do it.
> So please let me know if thats possible and if not what would be the
> solution to my problem.
>
> Thx
>
>

 
Reply With Quote
 
malpropio
Guest
Posts: n/a
 
      5th Mar 2007
Thk u Tom and Jim,
But I don't know if its because I'm using the vb code editor of excel
but when I right click on the userform in the project explorer it does
not give me the choice to delete it.

malpropio

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      5th Mar 2007
You must right click on the form you want to remove, not just in the project
window.

"malpropio" wrote:

> Thk u Tom and Jim,
> But I don't know if its because I'm using the vb code editor of excel
> but when I right click on the userform in the project explorer it does
> not give me the choice to delete it.
>
> malpropio
>
>

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      6th Mar 2007
If you want to do this by code, set a reference to the VBA 5.3 Extensibility
Library (in VBA, go to the Tools menu, choose References, and check
"Microsoft Visual Basic For Applications Extensibility Library 5.3"). Then
use code like

Sub DeleteForm()
Dim VBComps As VBIDE.VBComponents
Dim VBComp As VBIDE.VBComponent
Set VBComps = Workbooks("Book1.xls").VBProject.VBComponents
Set VBComp = VBComps("UserForm1")
VBComps.Remove VBComp
End Sub

See www.cpearson.com/excel/vbe.htm for more details and example code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"malpropio" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hey everyone,
> I'm trying to get rid of a form I created in a project so I can
> import another one which has the same name.
> But so far I havent been able to find a way to do it.
> So please let me know if thats possible and if not what would be the
> solution to my problem.
>
> Thx
>



 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      6th Mar 2007
Or, simpler, without needing a library reference:

Sub DeleteForm()
With Workbooks("Book1.xls").VBProject.VBComponents
.Remove .Item("UserForm1")
End With
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Chip Pearson" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> If you want to do this by code, set a reference to the VBA 5.3
> Extensibility Library (in VBA, go to the Tools menu, choose References,
> and check "Microsoft Visual Basic For Applications Extensibility Library
> 5.3"). Then use code like
>
> Sub DeleteForm()
> Dim VBComps As VBIDE.VBComponents
> Dim VBComp As VBIDE.VBComponent
> Set VBComps = Workbooks("Book1.xls").VBProject.VBComponents
> Set VBComp = VBComps("UserForm1")
> VBComps.Remove VBComp
> End Sub
>
> See www.cpearson.com/excel/vbe.htm for more details and example code.
>
>
> --
> Cordially,
> Chip Pearson
> Microsoft MVP - Excel
> Pearson Software Consulting, LLC
> www.cpearson.com
> (email address is on the web site)
>
> "malpropio" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hey everyone,
>> I'm trying to get rid of a form I created in a project so I can
>> import another one which has the same name.
>> But so far I havent been able to find a way to do it.
>> So please let me know if thats possible and if not what would be the
>> solution to my problem.
>>
>> Thx
>>

>
>



 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      6th Mar 2007
I didn't say to right click on the userform itself. Re read my post.

All actions are performed in the project explorer window (defaults to the
upper left of the VBE). You right click on the name of the Useform as
shown in the project explorer.

--
Regards,
Tom Ogilvy

"malpropio" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thk u Tom and Jim,
> But I don't know if its because I'm using the vb code editor of excel
> but when I right click on the userform in the project explorer it does
> not give me the choice to delete it.
>
> malpropio
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userforms =?Utf-8?B?WmFhaGly?= Microsoft Excel Programming 4 25th Oct 2006 12:53 PM
Userforms =?Utf-8?B?SmFzb24gWmlzY2hrZQ==?= Microsoft Excel Programming 1 25th Jan 2006 11:44 PM
userforms john.9.williams@bt.com Microsoft Excel Programming 0 16th Feb 2005 06:48 PM
UserForms Steved Microsoft Excel Misc 2 29th Jul 2004 09:43 AM
Delete Modules and Userforms Peter Pantus Microsoft Excel Programming 1 26th Sep 2003 08:17 PM


Features
 

Advertising
 

Newsgroups
 


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