ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sht and wrkbook proc copy (https://www.excelbanter.com/excel-programming/408891-sht-wrkbook-proc-copy.html)

x [email protected]

sht and wrkbook proc copy
 
Dim comS As VBIDE.VBComponent, comD As VBIDE.VBComponent, wbS, wbD, codM
As CodeModule, srshtS, srshtD
Dim comsS As VBIDE.VBComponents, comsD As VBIDE.VBComponents
Set comsS = ThisWorkbook.VBProject.VBComponents
Set comsD = Workbooks("ha.xls").VBProject.VBComponents

For Each comS In comsS
If comS.Type = vbext_ct_Document Then
Set codM = comS.CodeModule
srcodS = codM.Lines(1, codM.CountOfLines)
For Each comD In comsD
If comD.Type = vbext_ct_Document Then
srshtS = comS.Properties("name")
srshtD = comD.Properties("name")
If srshtS = srshtD Or codM = "ThisWorkbook" Then
comD.CodeModule.AddFromString srcodS 'error line
Exit For 'error line
End If
End If
Next
End If
Next

I want to copy sheets and thisworkbook procedures between
projects.......
but,,, error ..... ooooooooooh
error occur, and the excel application is killed







*** Sent via Developersdex http://www.developersdex.com ***

Barb Reinhardt

sht and wrkbook proc copy
 
YOu should be able to find something here to help you.

http://www.cpearson.com/excel/vbe.aspx

I believe if you copy the sheet, you get the code that's tied to it.
--
HTH,
Barb Reinhardt



"x " wrote:

Dim comS As VBIDE.VBComponent, comD As VBIDE.VBComponent, wbS, wbD, codM
As CodeModule, srshtS, srshtD
Dim comsS As VBIDE.VBComponents, comsD As VBIDE.VBComponents
Set comsS = ThisWorkbook.VBProject.VBComponents
Set comsD = Workbooks("ha.xls").VBProject.VBComponents

For Each comS In comsS
If comS.Type = vbext_ct_Document Then
Set codM = comS.CodeModule
srcodS = codM.Lines(1, codM.CountOfLines)
For Each comD In comsD
If comD.Type = vbext_ct_Document Then
srshtS = comS.Properties("name")
srshtD = comD.Properties("name")
If srshtS = srshtD Or codM = "ThisWorkbook" Then
comD.CodeModule.AddFromString srcodS 'error line
Exit For 'error line
End If
End If
Next
End If
Next

I want to copy sheets and thisworkbook procedures between
projects.......
but,,, error ..... ooooooooooh
error occur, and the excel application is killed







*** Sent via Developersdex
http://www.developersdex.com ***


x [email protected]

sht and wrkbook proc copy
 

hey, barb!
I know the site already......
I did many method for acomplishment the object...
But, I failed....
the stadard module, class module, form module is succed.. but the sht,
and thisworkbook module.... is difficult...

I want to get help from anyone.



*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 08:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com