jb
Member
I have written below code to copy current worksheet to another workbook at desired location. This VBA code works perfectly.
My current worksheet has 2 buttons and one image.
I have used Application.CopyObjectsWithCells = False and Application.CopyObjectsWithCells = True for not copying objects in new workbook.
that works fine. But it removes 2 buttons alongwith image in new workbook.
But I want to copy image not the buttons.
I have tried a loop which is given in comments in below code. This loop is not working that's why commented.
Suggest changes please.
	
		
				
			My current worksheet has 2 buttons and one image.
I have used Application.CopyObjectsWithCells = False and Application.CopyObjectsWithCells = True for not copying objects in new workbook.
that works fine. But it removes 2 buttons alongwith image in new workbook.
But I want to copy image not the buttons.
I have tried a loop which is given in comments in below code. This loop is not working that's why commented.
Suggest changes please.
>>> How many times have to give same note? <<<
>>> use code - tags <<<
	
	
>>> use code - tags <<<
		Code:
	
	Sub save_consolidated()
   Dim NewWb As Workbook
   Dim ws As Worksheet
   Dim fname As Variant
   Dim wbname As String
   Dim s As Shape
   wbname = "Consolidated Activity Leave " + ActiveWorkbook.Sheets("Consolidated").Range("N1")
   fname = Application.GetSaveAsFilename(InitialFileName:=wbname, filefilter:=" Excel Macro Free Workbook (*.xlsx), *.xlsx,")
     
   
   Application.CopyObjectsWithCells = False
   'copy your sheet
   ActiveSheet.Copy
   Application.CopyObjectsWithCells = True 'reset
  
   Set NewWb = ActiveWorkbook
  
   NewWb.SaveAs fname, FileFormat:=51, CreateBackup:=False
  
   'For Each s In ActiveSheet.Shapes
   'MsgBox s.Name
    'Select Case s.Name
        'Case "Picture 1"
            ' do nothing
        'Case Else
                's.Delete
        'End Select
   'Next s
  
   NewWb.Close False
 
   Set NewWb = Nothing
  
End Sub
			
				Last edited by a moderator: 
			
		
	
								
								
									
	
								
							
							 
	 
 
		