View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
ole_ ole_ is offline
external usenet poster
 
Posts: 30
Default Removing commandbuttons on "save as"

Bob, how do i save it without removing the commandbuttons.

When i put the code in Thisworkbook like this:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
'----------------------------------------------------------------
'Sub RemoveShapes()
'----------------------------------------------------------------
Dim shp As Shape
Dim sTopLeft As String
Dim fOK As Boolean

For Each shp In ActiveSheet.Shapes

fOK = True

testStr = ""
On Error Resume Next
sTopLeft = shp.TopLeftCell.Address
'Autofilter and Data Validation dropdowns
'don't seem to have a topleftcell address.
On Error GoTo 0

If shp.Type = msoFormControl Then
If shp.FormControlType = xlDropDown Then
If testStsTopLeftr = "" Then
'keep it
fOK = False
End If
End If
End If

If fOK Then
shp.Delete
End If

Next shp

End Sub


The new workbook is without commandbuttons, but also pricelist.xls is
without commandbutton's?

How can i save the code in pricelist.xls without removing the
commandbuttons, don't ask me how i did
it in the test file, i still have the test file and it's with CB.

Ole