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: 7,247
Default A few problems Programming to the Visual Basic Editor

Peter,

1. How do I change the name of a worksheet Sheet9(Margin) to
Margin(Margin) as seen in the VBE.


You can change the Name property of the VBComponent. For example,

ActiveWorkbook.VBProject.VBComponents("Sheet9").Na me = "Margin"

2. How can I update the code in Workings sheet and the code in Margin
sheet in the same procedure. Currently I can update One or the Other
but not both using the code below:


I'm not sure I understand you question. I THINK you can just pass the
VBComponet name to you AddWorkingsProcedure procedure.

AddWorkingsProcedure wbTarget, _
ActiveWorkbook.VBProject.VBComponents("Workings"). Name
AddWorkingsProcedure wbTarget, _
ActiveWorkbook.VBProject.VBComponents("Margin").Na me

Perhaps you could provide a bit more detail about what you are trying to
accomplish. You might also find the following page useful:
http://www.cpearson.com/excel/codemods.htm


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



"Peter McNaughton" wrote in message
om...
Hi,
I have found Chip Pearson's web pages very helpful but still have a
couple of problems.

1. How do I change the name of a worksheet Sheet9(Margin) to
Margin(Margin) as seen in the VBE.

2. How can I update the code in Workings sheet and the code in Margin
sheet in the same procedure. Currently I can update One or the Other
but not both using the code below:

Thanks in advance
Peter

Sub AddCodeToSheetModule()
'No error handling!!
Dim strShtName As String
Dim wbTarget As Workbook
Dim VBComp As VBIDE.VBComponent

strShtName = "Workings"

Set wbTarget = Workbooks.Open("C:\coster 2\Angus.std")

strShtName = "Workings"
With wbTarget.Worksheets(strShtName)
For Each VBComp In .Parent.VBProject.VBComponents
If VBComp.Type = vbext_ct_Document And VBComp.Name =
strShtName Then
AddWorkingsProcedure wbTarget, strShtName
Exit For
End If
Next
End With

strShtName = "Margin"
With wbTarget.Worksheets(strShtName)
For Each VBComp In .Parent.VBProject.VBComponents
If VBComp.Type = vbext_ct_Document And VBComp.Name =
strShtName Then
AddMarginProcedure wbTarget, strShtName
Exit For
End If
Next
End With
End Sub



 
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
Opening Visual Basic Editor SteveG[_5_] Excel Discussion (Misc queries) 0 March 19th 09 01:46 PM
Visual Basic Editor Ron Rueter Excel Discussion (Misc queries) 3 October 28th 08 02:48 PM
Password in Visual basic editor Tia[_3_] Excel Worksheet Functions 0 July 11th 08 08:40 AM
Visual Basic Editor opens bi itself KG Excel Discussion (Misc queries) 0 September 15th 07 04:02 PM
Visual basic editor Answerfactory Excel Discussion (Misc queries) 3 October 9th 06 09:13 PM


All times are GMT +1. The time now is 11:59 PM.

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"