vba excel: how to copy worksheet with images but without buttons -


i have worksheet image , 2 buttons. (invoice) copy worksheet image without 2 buttons new sheet of new workbook , wanna vba macro. in moment usual copy command , use delete command 2 buttons.

i sure there easier way it. tried this...

application.copyobjectswithcells = false sheets("invoice").select sheets("invoice").move after:=workbooks("invoices").sheets(1) application.copyobjectswithcells = true 

these looses buttons image gone. keep image.

i hope guys can me this.

thanks in advance.

the explanations in comments in code below:

option explicit  sub copysheet_wo_btn()  dim newwb                       workbook dim shtorig                     worksheet  dim obj                         oleobject dim picshape                    shape dim picleft                     double dim pictop                      double  set shtorig = thisworkbook.sheets("invoice")  ' loop through objects in "invoice" sheet each obj in shtorig.oleobjects      ' if ole object type commanbutton make un-visible (not copy sheet)     if obj.progid = "forms.commandbutton.1"         obj.visible = false     end if  next obj  set newwb = workbooks.add(xlwbatworksheet) shtorig.copy newwb.sheets(1)  ' loop through shapes in "invoice" sheet , copy pictures each picshape in shtorig.shapes     if picshape.name = "picture 1"         picleft = picshape.left         pictop = picshape.top         picshape.copy          newwb.sheets(1).paste         selection.shaperange.left = picleft         selection.shaperange.top = pictop     end if next picshape  ' loop again , return commandbuttons visible in "invoice" sheet each obj in shtorig.oleobjects     obj.visible = true next obj  end sub 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -