For Each objVBComp in objMyProj.VBComponents
If objVBComp.Type = vbtext_ct_StdModule Then
objVBComp.Export "C:\filepath\" & objVBComp.Name & ".bas"
Elseif objVBComp.Type = "100" Then
comname = objVBComp.Name
If comname = "ThisWorkbook" Then
objVBComp.Export "C:\filepath\" & objVBComp.Name & ".cls"
Else
sheetnum = Right(comname, Len(comname)-5)
[COLOR=rgb(147, 101, 184)]With ThisWorkbook[/COLOR]
[COLOR=rgb(147, 101, 184)] [/COLOR][COLOR=rgb(41, 105, 176)]sheetname[/COLOR][COLOR=rgb(65, 168, 95)] =[/COLOR][COLOR=rgb(147, 101, 184)] .Sheets(.VBProject.VBComponents("Sheet" & [/COLOR][COLOR=rgb(41, 105, 176)]sheetnum[/COLOR][COLOR=rgb(147, 101, 184)]).Properties("index")).Name[/COLOR]
[COLOR=rgb(147, 101, 184)]End With[/COLOR]
If wkb is Nothing Then Set wkb = ActiveWorkbook
[COLOR=rgb(65, 168, 95)]' For checking if sheet is visible, not hidden[/COLOR]
If wkb.Sheets(sheetname).visible = xlSheetVisible Then
objVBComp.Export "C:\filepath\" & objVBComp.Name & " (" & sheetname & ").cls"
Else
[COLOR=rgb(65, 168, 95)] 'skip, sheet is hidden[/COLOR]
End If
End If
End If
Next