Use VBA to copy an image from headers/footers of one sheet to another

六月ゝ 毕业季﹏ 提交于 2019-12-02 01:38:40

Excel has a handy Record Macro function.

You can initiate that, Copy the footer over, then stop the recording.

Then, review the code, and it should pretty much show you how to do it.

If you are working in anything older than Excel 2007 then it doesn't sound like this is possible without using the original graphic file (e.g. JPG, GIF etc):

Normally, you can copy and paste the headers and footers from one worksheet to another by selecting the worksheets and then using the Header or Footer dialog boxes (click Custom Header or Custom Footer on the Header/Footer tab of the Page Setup dialog box). However, if the original headers and footers contain graphics, the graphics will not propagate to the other worksheets. The only way to work with pictures in headers or footers for multiple worksheets is to select all the worksheets, and then insert a graphic by using the Insert Picture dialog box (click the Insert Picture button), or format the graphic by using the Format Picture dialog box (click the Format Picture button). The original graphic file is needed for this procedure.

source

It may be possible in Excel 2007 - see here

One workaround is to copy the original worksheet to the new workbook:

   ' macro on the source workbook
    Sheets("Sheet1").Move After:=Workbooks("Book2").Sheets(3)

When you do this, you get a worksheet in the destination workbook with all the features of the original, including footers and headers, you can then copy all the content you want into the new worksheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!