oggi giornata di finalizzazione di files.
con la macro nuovofile ottengo il risultato. Ma nel nuovo file mi trascino anche bottoni e icone presenti nel master.
Come posso evitarlo ?
Per capire, ho provato utilizzando il registratore ma il risultato non c'è stato.
- Codice: Seleziona tutto
Sub nuovofile()
'dichiaro le variabili
Dim wk1 As Workbook
'Dim wk2 As Workbook
Dim sh1 As Worksheet
'Dim sh2 As Worksheet
'gestione errori
On Error GoTo RigaErrore
'metto i riferimenti ai files
Set wk1 = ThisWorkbook
'Set wk2 = Workbooks("infortunio___.xlsx")
'metto i riferimenti ai fogli
Set sh1 = wk1.Worksheets("Sheet1")
'Set sh2 = wk2.Worksheets("Sheet1")
With sh1
'copio i dati da un file all'altro
'Range("A1:AA69").Select
'Range("AA69").Activate
Sheets("Incident Investigation").Select
Sheets("Incident Investigation").Copy
ChDir "C:\Users\Microsoft\Desktop\Appoggio"
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\Microsoft\Desktop\Appoggio\macro da fare\infortunio___.xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
End With
'ActiveSheet.Shapes.Range(Array("Immagine 6")).Select
'Selection.Delete
'ActiveSheet.Shapes.Range(Array("Immagine 2")).Select
'Selection.Delete
'ActiveSheet.Shapes.Range(Array("Immagine 4")).Select
'Range("AD36").Select
'ActiveSheet.Shapes.Range(Array("btnDateReported")).Select
'Selection.Delete
'Selection.Cut
' ActiveSheet.Shapes.Range(Array("btnDateReported")).Select
'Selection.Delete
'Selection.Cut
' ActiveSheet.Shapes.Range(Array("btnIncDes")).Select
'Selection.Delete
' Selection.Cut
' ActiveSheet.Shapes.Range(Array("btnDateIncident")).Select
' Selection.Delete
' Selection.Cut
' ActiveSheet.Shapes.Range(Array("btnLocation")).Select
' Selection.Delete
' Selection.Cut
' ActiveSheet.Shapes.Range(Array("btnConditions")).Select
' Selection.Delete
' Selection.Cut
' ActiveWindow.SmallScroll Down:=3
' ActiveSheet.Shapes.Range(Array("btnEquipment")).Select
' Selection.Delete
' Selection.Cut
'ActiveSheet.Shapes.Range(Array("btnInjBody")).Select
' Selection.Delete
' Selection.Cut
' ActiveWindow.SmallScroll Down:=6
'ActiveSheet.Shapes.Range(Array("btnInjNature")).Select
' Selection.Delete
' Selection.Cut
' ActiveWindow.SmallScroll Down:=30
' ActiveSheet.Shapes.Range(Array("btnImmeChse")).Select
' Selection.Delete
' Selection.Cut
' ActiveWindow.SmallScroll Down:=18
' Range("D70:AA110").Select
' Range("AA110").Activate
' ActiveSheet.Shapes.Range(Array("btnPrintSave")).Select
' Selection.Delete
' Selection.Cut
' ActiveSheet.Shapes.Range(Array("btnPrintSave")).Select
'Selection.Delete
' Selection.Cut
' ActiveSheet.Shapes.Range(Array("btnEmailForm")).Select
' Selection.Delete
' Selection.Cut
' ActiveSheet.Shapes.Range(Array("btnEmailForm")).Select
' Selection.Delete
' Selection.Cut
' ActiveSheet.Shapes.Range(Array("btnEmailForm")).Select
' Selection.Delete
' Selection.Cut
' Range("F117").Select
' ActiveSheet.Shapes.Range(Array("Immagine 5")).Select
' Selection.Cut
' ActiveSheet.Shapes.Range(Array("Immagine 7")).Select
' Selection.Cut
' ActiveSheet.Shapes.Range(Array("Immagine 4")).Select
' Selection.Cut
' ActiveSheet.Shapes.Range(Array("Immagine 2")).Select
' Selection.Cut
' ActiveSheet.Shapes.Range(Array("Immagine 6")).Select
' Selection.Cut
'ActiveWorkbook.Save
'ActiveWindow.Close
'riga sempre eseguita
RigaChiusura:
'Set a Nothing delle variabili oggetto
Set sh2 = Nothing
Set sh1 = Nothing
Set wk1 = Nothing
Set wk2 = Nothing
Exit Sub
'in caso di errore
RigaErrore:
MsgBox Err.Number & vbNewLine & Err.Description
Resume RigaChiusura
End Sub
Grazie per l'aiuto.....bis...
https://www.dropbox.com/s/a4kdm9qu8su2c2e/Incident-Investigation%20vForum.xlsm?dl=0