View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Problem with save some code

Hi ole,

That code looks familiar <G.

Do you have both of those BeforeSave events in both workbooks? If not, why
are you showing us two?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"ole_" wrote in message
...
Hi,

I have a huge problem, i have 2 pricelist one national an one

international
both are exactly the
same only the language is different, here comes my problem they are XLS
files and due to other
reasons they cant be XLT, i have some code that deletes my commandbuttons
when they "save as"
because i dont want that the commandbottuns one the file to the customer.

And here comes my real problem i have managed to save the code below

without
deleting the
commandbuttons in the national version but can't do it in the int. version
and i really dont now
how i did it?? :-(

I also have a Enableevent when the national succeded but again how?

Here it comes

'Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
'Application.EnableEvents = False
'ActiveWorkbook.Save
'Application.EnableEvents = True
'End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If SaveAsUI = False Then
MsgBox "Remember to 'Save As' when you want to save this file",

vbCritical

Cancel = True
End If



'----------------------------------------------------------------
'Sub RemoveShapes()
'----------------------------------------------------------------
Dim shp As Shape
Dim sTopLeft As String
Dim fOK As Boolean

Worksheets("4 Farver").Activate

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

Worksheets("6 Farver").Activate

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

Worksheets("8 Farver ").Activate

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