Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JYH JYH is offline
external usenet poster
 
Posts: 4
Default re-creating vbcomponent

I am trying to create a UserForm X. If, for whatever reason, form X
already exist, I want to remove it and re-create it again.

Sounds simple, right?

Here's the code:
Dim TempForm As Object ' VBComponent
On Error Resume Next
Set TempForm = ThisWorkbook.VBProject.VBComponents("Bob")
ThisWorkbook.VBProject.VBComponents.Remove TempForm
On Error GoTo 0
'Set TempForm = Nothing
Set TempForm =
ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_M SForm)
ThisWorkbook.VBProject.VBComponents(TempForm.name) .name = "Bob"

Last line gives me a "Run time error 75: path file access error"...

Any suggestion?

And, before you ask, even god have less privilege than me on that
machine...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default re-creating vbcomponent

It seems that VB considers component Bob to exist even after removed. An
intermediate save fixed that for me in Excel 2010:

Sub a()
Dim TempForm As Object ' VBComponent
On Error Resume Next
Set TempForm = ThisWorkbook.VBProject.VBComponents("Bob")
ThisWorkbook.VBProject.VBComponents.Remove TempForm
On Error GoTo 0
ThisWorkbook.Save
ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_M SForm).Name = "Bob"
End Sub

Jim

"JYH" wrote in message
...
I am trying to create a UserForm X. If, for whatever reason, form X
already exist, I want to remove it and re-create it again.

Sounds simple, right?

Here's the code:
Dim TempForm As Object ' VBComponent
On Error Resume Next
Set TempForm = ThisWorkbook.VBProject.VBComponents("Bob")
ThisWorkbook.VBProject.VBComponents.Remove TempForm
On Error GoTo 0
'Set TempForm = Nothing
Set TempForm =
ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_M SForm)
ThisWorkbook.VBProject.VBComponents(TempForm.name) .name = "Bob"

Last line gives me a "Run time error 75: path file access error"...

Any suggestion?

And, before you ask, even god have less privilege than me on that
machine...


  #3   Report Post  
Posted to microsoft.public.excel.programming
JYH JYH is offline
external usenet poster
 
Posts: 4
Default re-creating vbcomponent


Thank you but I would prefer not to save someone else's workbook. (I
realised I meant ACTIVEWORKBOOK and <Unot</U THISWORKBOOK.)

However you seem to have pointed something the Since it is
understandable that you can not re-use a component until its
eradication have been confirm by a save, my best solution may be to
use it and delete its content. But then, not only would I make it
harder to clean (each and every component) but also would most likely
get the same problem when I will try to re-add the same controls...
( A textbox name X on a form Y could not be re-created under the same
name after being suppressed once from that same form...)



On 28 avr, 12:15, "Jim Rech" wrote:
It seems that VB considers component Bob to exist even after removed. *An
intermediate save fixed that for me in Excel 2010:

Sub a()
* * Dim TempForm As Object ' VBComponent
* * On Error Resume Next
* * Set TempForm = ThisWorkbook.VBProject.VBComponents("Bob")
* * ThisWorkbook.VBProject.VBComponents.Remove TempForm
* * On Error GoTo 0
* * ThisWorkbook.Save
* * ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_M SForm).Name = "Bob"
End Sub

Jim

"JYH" wrote in message

...



I am trying to create a UserForm X. If, for whatever reason, form X
already exist, I want to remove it and re-create it again.


Sounds simple, right?


Here's the code:
Dim TempForm As Object ' VBComponent
On Error Resume Next
* *Set TempForm = ThisWorkbook.VBProject.VBComponents("Bob")
* *ThisWorkbook.VBProject.VBComponents.Remove TempForm
On Error GoTo 0
* *'Set TempForm = Nothing
* *Set TempForm =
ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_M SForm)
* *ThisWorkbook.VBProject.VBComponents(TempForm.name ).name = "Bob"


Last line gives me a "Run time error 75: path file access error"...


Any suggestion?


And, before you ask, even god have less privilege than me on that
machine...- Masquer le texte des messages précédents -


- Afficher le texte des messages précédents -

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
VBComponent documentation Phil Hibbs Excel Programming 1 January 7th 10 09:55 AM
Can't pass VBComponent to Sub Procedure in VB.Net ExcelMonkey Excel Programming 0 October 21st 09 06:59 AM
VBIDE.VBComponent michaelberrier Excel Discussion (Misc queries) 3 June 12th 06 05:47 PM
VBComponent Types Todd Huttenstine Excel Programming 1 May 11th 04 08:16 PM
Relating Worksheet(I).Name with VBComponent(J).Name MWE[_5_] Excel Programming 1 January 20th 04 08:51 PM


All times are GMT +1. The time now is 09:49 PM.

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"