-
Still Having Problem
I use the below code to copy
[VBA]Sub TheSub()
ActiveWorkbook.Save
On Error Resume Next
Application.ScreenUpdating = False
TargetFileName = "c:\test\copy_" & ThisWorkbook.Name
Workbooks(ThisWorkbook.Name).SaveCopyAs TargetFileName
DeleteAllVBACode (TargetFileName)
End Sub
[/VBA]
I use the below code to delete the VBA
[VBA]Sub DeleteAllVBACode(TargetFileName As String)
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Set VBProj = ActiveWorkbook.VBProject
For Each VBComp In VBProj.VBComponents
If VBComp.Type = vbext_ct_Document Then
Set CodeMod = VBComp.CodeModule
With CodeMod
.DeleteLines 1, .CountOfLines
End With
Else
VBProj.VBComponents.Remove VBComp
End If
Next VBComp
End Sub
[/VBA]
It is not working even I use the below code
[VBA]Set VBProj = Workbooks(TargetFileName).VBProject [/VBA]
Please help.
Regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules