Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default VBComponents question

Hi all,

I need to programmatically add codes to a sheet module which has been
renamed previously.

Let's say such module's internal name is Sheet8, but the sheet has been
renamed as, say "ABCDE".

Now I found that I could not properly refers to that sheet's module by
writing VBProject.VBComponents("ABCDE"), but
VBProject.VBComponents("Sheet8") will be fine.

My question is, is it ever possible to refer to that VB Component with
"ABCDE", and not "Sheet8"? This is necessary because the original sheet name
("Sheetx") differs each time when I need to add code to it. Thanks for your
assistance.

Frederick Chow
Hong Kong.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default VBComponents question

not directly.

you can do

For Each vbc In ThisWorkbook.VBProject.vbcomponents
If vbc.Type = vbext_ct_Document Then
If vbc.Name < "ThisWorkbook" Then
If vbc.Properties("Name") = "ABCDE" Then
s = vbc.Properties("_codename").Value
Set vbc1 = vbc
Exit For
End If
End If
End If
Next
MsgBox s & ", " & vbc.Name
End Sub

so vbc1 will be a reference to the component (or you have the name in s or
you could get it with vbc1.name)

--
Regards,
Tom Ogilvy

"Frederick Chow" wrote:

Hi all,

I need to programmatically add codes to a sheet module which has been
renamed previously.

Let's say such module's internal name is Sheet8, but the sheet has been
renamed as, say "ABCDE".

Now I found that I could not properly refers to that sheet's module by
writing VBProject.VBComponents("ABCDE"), but
VBProject.VBComponents("Sheet8") will be fine.

My question is, is it ever possible to refer to that VB Component with
"ABCDE", and not "Sheet8"? This is necessary because the original sheet name
("Sheetx") differs each time when I need to add code to it. Thanks for your
assistance.

Frederick Chow
Hong Kong.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Thanks a lot (No Content)


"Tom Ogilvy" wrote in message
...
not directly.

you can do

For Each vbc In ThisWorkbook.VBProject.vbcomponents
If vbc.Type = vbext_ct_Document Then
If vbc.Name < "ThisWorkbook" Then
If vbc.Properties("Name") = "ABCDE" Then
s = vbc.Properties("_codename").Value
Set vbc1 = vbc
Exit For
End If
End If
End If
Next
MsgBox s & ", " & vbc.Name
End Sub

so vbc1 will be a reference to the component (or you have the name in s or
you could get it with vbc1.name)

--
Regards,
Tom Ogilvy

"Frederick Chow" wrote:

Hi all,

I need to programmatically add codes to a sheet module which has been
renamed previously.

Let's say such module's internal name is Sheet8, but the sheet has been
renamed as, say "ABCDE".

Now I found that I could not properly refers to that sheet's module by
writing VBProject.VBComponents("ABCDE"), but
VBProject.VBComponents("Sheet8") will be fine.

My question is, is it ever possible to refer to that VB Component with
"ABCDE", and not "Sheet8"? This is necessary because the original sheet
name
("Sheetx") differs each time when I need to add code to it. Thanks for
your
assistance.

Frederick Chow
Hong Kong.





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
Changeing codename of worksheet via VBComponents collection Arne Excel Programming 3 July 13th 05 12:13 PM
?thisworkbook.VBComponents(5).Type returns 2 [email protected][_2_] Excel Programming 1 December 13th 04 06:13 PM
Links between VBComponents and Sheets 3 Paul Excel Programming 1 August 5th 04 04:38 PM
Links between VBComponents and Sheets 2 Paul Excel Programming 1 August 5th 04 04:59 AM
Links between VBcomponents and Sheets Bernie Deitrick Excel Programming 1 August 4th 04 07:19 PM


All times are GMT +1. The time now is 01: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"