IF the user has ENABLED access to the VB object model..
then I suggest you use some code to clear the modules.
just google or go to Chip Pearson's site for some example code.
Else.. i've made this one..
saves as xmlSpreadsheet (xlXP+)..then reopens and saves as .xls
you'll get rid of the macro's but it also clears any objects.
formulas,formatting,validation etc are preserved.
Plus it's slow
Sub SaveCopyWithoutMacros()
Dim sFull$, sTemp$, sPath$, sFile$
sFull = Application.GetSaveAsFilename("Copy of " & ActiveWorkbook.Name)
If sFull = vbNullString Then
Exit Sub
ElseIf Right(sFull, 1) = "." Then
sFull = sFull & "xls"
End If
If Dir(sFull) <> vbNullString Then
If vbCancel = MsgBox("File Exists!. OverWrite?)", vbOKCancel) Then
Exit Sub
End If
Kill sFull
End If
sPath = Left$(sFull, InStrRev(sFull, "\") - 1) & "\"
sFile = Mid$(sFull, InStrRev(sFull, "\") + 1)
sTemp = Environ("Temp") & "\"
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.EnableEvents = False
'First save a copy in the tempdir
ActiveWorkbook.SaveCopyAs sTemp & sFile
'Open the copy , save as xml
With Workbooks.Open(sTemp & sFile)
.SaveAs sTemp & Replace(sFile, "xls", "xml"), xlXMLSpreadsheet
.Close 0
End With
'open the xml, save as xls in final destination
With Workbooks.Open(sTemp & Replace(sFile, "xls", "xml"))
.SaveAs sFull, xlWorkbookNormal
.Close 0
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.EnableEvents = True
Kill sTemp & sFile
Kill sTemp & Replace(sFile, "xls", "xml")
End Sub
keepITcool
< email : keepitcool chello nl (with @ and .) >
< homepage:
http://members.chello.nl/keepitcool >