Ciao Claudio,
fatto prova .....nuovo foglio non ha ne pulsanti ne formule ....foglio origine ha il Pulsante .... Funziona ......??
Devo provare il codice con il mio file ????
sotto screenshot
[Cut]

Visto lo screenshot che non ho tolto, mi pare che vada bene, anche se non credo che la modifica del mio codice per esplicitamente cancellare eventuali pulsanti avrebbe dovuto essere necessario. Tuttavia, mi pare che non tutto vada bene in questa vita - per
assoluta conferma di questa ipotesi basta considerare il risultato ieri sera! (;-
Ad ogni modo, ho modificato il codice, qui sotto e nel file su DropBox, per commentare i tre MsgBox, e ti chiederei di provalo con il tuo file. Se, anche così, tutto vada bene avrai risparmiato il sale e l'aglio e potresti chiudere il thread definitivamente.
'=========>>
Option Explicit
'--------->>
Public Sub CopiaFoglio()
Dim WB As Workbook
Dim DDir As String, NewFname As String
Dim iButtons As Long
Const FPrefix = "Pippo - " '<<=== Modifica
Set WB = ThisWorkbook
'\ Seleziona la cartella destinazione in DDir
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = DDir '\ Filtro per nome
.Title = "Scegli la directory per il foglio " & ActiveSheet.Name
.Show
If .SelectedItems.Count = 0 Then '\directory non scelta
MsgBox ("Scelta non effettuata, procedura abortita")
Exit Sub
End If
DDir = .SelectedItems(1) & ""
End With
'\ Copia il foglio in un'altro al volo
'\ Converte tutte le formule del foglio nel
'\ valore al momento calcolato
With ActiveSheet
.Copy
With .UsedRange
.Value = .Value
End With
End With
'\ Salva il foglio
NewFname = DDir & FPrefix & ActiveSheet.Name & ".xlsx"
Application.DisplayAlerts = False
With ActiveWorkbook
With .Sheets(1)
iButtons = .Buttons.Count
Call MsgBox( _
Prompt:=iButtons & " pulsanti trovati sul foglio " _
& .Name & " del file " & .Parent.Name, _
Buttons:=vbInformation, _
Title:="REPORT #1")
If CBool(iButtons) Then
.Buttons.Delete
' Call MsgBox( _
' Prompt:=iButtons & " pulsanti trovati sul foglio " _
' & .Name & " del file " & .Parent.Name, _
' Buttons:=vbInformation, _
' Title:="REPORT #2")
End If
.SaveAs Filename:=NewFname, FileFormat:=51
' Call MsgBox(Prompt:="Il foglio " & .Name _
' & " del file" _
' & NewFname _
' & vbNewLine _
' & "comprende:" _
' & vbNewLine & vbNewLine _
' & ActiveSheet.Shapes.Count & vbTab & " Oggetti Shape; " _
' & vbNewLine _
' & .Buttons.Count & vbTab & "Pulsante Modulo" _
' & vbNewLine _
' & .OLEObjects.Count & vbTab & "Controlli ActiveX", _
' Buttons:=vbInformation, _
' Title:="DETECT PHANTOM BUTTON")
End With
.Close
End With
With ActiveSheet
' Call MsgBox(Prompt:="Il foglio " & .Name _
' & " del file" _
' & ActiveWorkbook.Name _
' & vbNewLine _
' & "comprende:" _
' & vbNewLine & vbNewLine _
' & ActiveSheet.Shapes.Count & vbTab & " Oggetti Shape; " _
' & vbNewLine _
' & .Buttons.Count & vbTab & "Pulsante Modulo" _
' & vbNewLine _
' & .OLEObjects.Count & vbTab & "Controlli ActiveX", _
' Buttons:=vbInformation, _
' Title:="CONFERMA PRESENZA DEL BOTTONE")
End With
XIT:
Application.DisplayAlerts = True
End Sub
'<<=========
===
Regards,
Norman
