Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Removing & Importing user forms via code?


Can I programmatically remove a user form and then import a user from?

The reason is I have a many workbooks that all use the same form and I
updated the code in one of the workbooks and I want to update all the
others without having to manually open each one, then open VBA, then
hit remove and then import. This would take way too long.

Thanks for any help.


--
R-Enemy
------------------------------------------------------------------------
R-Enemy's Profile: http://www.excelforum.com/member.php...o&userid=16732
View this thread: http://www.excelforum.com/showthread...hreadid=319362

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Removing & Importing user forms via code?

Try something like the following:

With ActiveWorkbook.VBProject.VBComponents
.Remove .Item("UserForm1")
.Import Filename:="C:\whatever\userform1.frm"
End With

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


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"R-Enemy" wrote in message
...

Can I programmatically remove a user form and then import a
user from?

The reason is I have a many workbooks that all use the same
form and I
updated the code in one of the workbooks and I want to update
all the
others without having to manually open each one, then open VBA,
then
hit remove and then import. This would take way too long.

Thanks for any help.


--
R-Enemy
------------------------------------------------------------------------
R-Enemy's Profile:
http://www.excelforum.com/member.php...o&userid=16732
View this thread:
http://www.excelforum.com/showthread...hreadid=319362



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Removing & Importing user forms via code?

I'm still having a couple small problems...

1. It's not letting me remove a form and then import the new form right
away. It will remove the form but then give the error that the name exists
and can't import the new form. But, it will import the form the next time
through the Sub. (I'm using On Error Resume Next in case the form never
existed in the first place.)

2. Doing the same thing for a module it removes the module just fine but on
the import it adds a 1 to the module name, ex. "updater1" when it should be
just "updater"

Here's some of the code that I use:

Sub checkUpdates()
...
'If there's a newer version then...

'base has been set as Activeworkbook

Dim VBComp As Object
Set VBComp = base.VBProject.VBComponents("updater")
base.VBProject.VBComponents.Remove VBComp
base.VBProject.VBComponents.Import "K:\C-REPORT\VersionUpdate\updater.bas"

'this sub is contained inside updater
runUpdates

End Sub

Sub runUpdates()
On Error Resume Next

'up has been set to a workbook that tells what to remove,
'and the path of the file to be imported

Do While up.Sheets("Start").Cells(row, 1) < ""
Set VBComp = base.VBProject.VBComponents(up.Sheets("Start").Cel ls(row, 2))
base.VBProject.VBComponents.Remove VBComp
base.VBProject.VBComponents.Import up.Sheets("Start").Cells(row, 3)
row = row + 1
Loop

End Sub

I hope some of this makes sense.

Thanks for any help.

"Chip Pearson" wrote:

Try something like the following:

With ActiveWorkbook.VBProject.VBComponents
.Remove .Item("UserForm1")
.Import Filename:="C:\whatever\userform1.frm"
End With

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


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

Reply
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
Removing check boxes (forms toolbar) jvs Excel Worksheet Functions 1 November 11th 09 04:23 PM
Importing Alan Beban's code on Arrays; Importing a module or a project Steve G Excel Worksheet Functions 4 August 27th 07 04:18 PM
Importing multiple forms into a single Excel list Jacques Excel Discussion (Misc queries) 0 November 3rd 06 06:51 PM
how to add numbers from different areas in chart and importing forms from word carole New Users to Excel 1 June 12th 06 12:38 AM
Removing a user form with code KimberlyC Excel Programming 1 January 8th 04 11:55 PM


All times are GMT +1. The time now is 09:06 AM.

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

About Us

"It's about Microsoft Excel"