Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Removing commandbuttons on "save as"

Hi,

I have a XLS file called pricelist with 3 sheets and all with 14
commandbuttons, when the pricelist.xls
is "saved as" i dont want the commandbuttons to be saved only the data, but
they of cource still should
remain in pricelist.xls (when im finshed making it im going to make it to a
XLT file)

AHA.

Ole


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Removing commandbuttons on "save as"

Hi Ole,

How can they not be saved, yet remain?

--

HTH

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


"ole_" wrote in message
...
Hi,

I have a XLS file called pricelist with 3 sheets and all with 14
commandbuttons, when the pricelist.xls
is "saved as" i dont want the commandbuttons to be saved only the data,

but
they of cource still should
remain in pricelist.xls (when im finshed making it im going to make it to

a
XLT file)

AHA.

Ole




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Removing commandbuttons on "save as"

I have my Pricelist.xls with the commandbuttons and when that file is "save
as"
for exampel "march.xls" i dont want March.xls to have any commandbuttons
but they should still remain in pricelist.xls.

Ole


"Bob Phillips" skrev i en meddelelse
...
Hi Ole,

How can they not be saved, yet remain?

--

HTH

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


"ole_" wrote in message
...
Hi,

I have a XLS file called pricelist with 3 sheets and all with 14
commandbuttons, when the pricelist.xls
is "saved as" i dont want the commandbuttons to be saved only the data,

but
they of cource still should
remain in pricelist.xls (when im finshed making it im going to make it

to
a
XLT file)

AHA.

Ole






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Removing commandbuttons on "save as"

Okay, it was said actually, just6 didn't see it :-)

In the code just before the SaveAs, delete them. This code deletes all
shapes on a worksheet, including buttons. Just call this routine. You might
want to chyange ACtivesheet to a named sheet, such as Worksheets("Sheet1")


'----------------------------------------------------------------
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



--

HTH

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


"ole_" wrote in message
...
I have my Pricelist.xls with the commandbuttons and when that file is

"save
as"
for exampel "march.xls" i dont want March.xls to have any commandbuttons
but they should still remain in pricelist.xls.

Ole


"Bob Phillips" skrev i en meddelelse
...
Hi Ole,

How can they not be saved, yet remain?

--

HTH

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


"ole_" wrote in message
...
Hi,

I have a XLS file called pricelist with 3 sheets and all with 14
commandbuttons, when the pricelist.xls
is "saved as" i dont want the commandbuttons to be saved only the

data,
but
they of cource still should
remain in pricelist.xls (when im finshed making it im going to make it

to
a
XLT file)

AHA.

Ole








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Removing commandbuttons on "save as"

Bob, your a genius, ones again thanks.

and if it can comfort you i'm allmost done with my "project".

Ole


"Bob Phillips" skrev i en meddelelse
...
Okay, it was said actually, just6 didn't see it :-)

In the code just before the SaveAs, delete them. This code deletes all
shapes on a worksheet, including buttons. Just call this routine. You

might
want to chyange ACtivesheet to a named sheet, such as Worksheets("Sheet1")


'----------------------------------------------------------------
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



--

HTH

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


"ole_" wrote in message
...
I have my Pricelist.xls with the commandbuttons and when that file is

"save
as"
for exampel "march.xls" i dont want March.xls to have any commandbuttons
but they should still remain in pricelist.xls.

Ole


"Bob Phillips" skrev i en meddelelse
...
Hi Ole,

How can they not be saved, yet remain?

--

HTH

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


"ole_" wrote in message
...
Hi,

I have a XLS file called pricelist with 3 sheets and all with 14
commandbuttons, when the pricelist.xls
is "saved as" i dont want the commandbuttons to be saved only the

data,
but
they of cource still should
remain in pricelist.xls (when im finshed making it im going to make

it
to
a
XLT file)

AHA.

Ole












  #6   Report Post  
Posted to microsoft.public.excel.programming
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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Removing commandbuttons on "save as"

I think you got hit by Edit|replace:

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

For Each shp In ActiveSheet.Shapes

fOK = True

sTopLeft = ""
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 sTopLeft = "" Then
'keep it
fOK = False
End If
End If
End If

If fOK Then
shp.Delete
End If

Next shp

End Sub

sTopLeft and testStr were intermingled.


Bob Phillips wrote:

Okay, it was said actually, just6 didn't see it :-)

In the code just before the SaveAs, delete them. This code deletes all
shapes on a worksheet, including buttons. Just call this routine. You might
want to chyange ACtivesheet to a named sheet, such as Worksheets("Sheet1")

'----------------------------------------------------------------
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

--

HTH

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

"ole_" wrote in message
...
I have my Pricelist.xls with the commandbuttons and when that file is

"save
as"
for exampel "march.xls" i dont want March.xls to have any commandbuttons
but they should still remain in pricelist.xls.

Ole


"Bob Phillips" skrev i en meddelelse
...
Hi Ole,

How can they not be saved, yet remain?

--

HTH

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


"ole_" wrote in message
...
Hi,

I have a XLS file called pricelist with 3 sheets and all with 14
commandbuttons, when the pricelist.xls
is "saved as" i dont want the commandbuttons to be saved only the

data,
but
they of cource still should
remain in pricelist.xls (when im finshed making it im going to make it

to
a
XLT file)

AHA.

Ole







--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Removing commandbuttons on "save as"

If you going to make it an XLT, then the xlt will not be affected by any
code. It will only affect the workbook created from the xlt.

While working with the xlt, you should disable events before saving, or put
a check in your code so the shapes are not deleted if the userid is you (for
example). Or you can comment out the code until you convert the workbook
to an XLT.

--
Regards,
Tom Ogilvy



"ole_" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 ronhansen Excel Discussion (Misc queries) 1 November 15th 09 09:33 PM
"CELL("FILENAME") NOT UPDATE AFTER "SAVE AS" ACTION yossie6 Excel Discussion (Misc queries) 1 June 16th 08 12:16 PM
"Save" and "Save As" options greyed out - "Save as Webpage" option Bill Excel Discussion (Misc queries) 0 January 16th 07 04:47 PM
Removing "Save As" Command from an excel file. Camper Joe Excel Worksheet Functions 0 December 19th 05 03:00 PM
save and restore "Workbook Menu Bar" & "Cell" menus Jeff Higgins Excel Programming 2 February 14th 05 01:33 AM


All times are GMT +1. The time now is 12:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"