如何使用VBA将页面设置从工作表复制到另一个

如何将页面设置(包括工作表中的RightHeaderPicture)复制到使用VBA的另一台? 有人可以帮我吗? 问候,安东尼泰伦斯

有点枯燥,但你会完成的时候你的想法!

显然有没有简单的方法来复制完整的PageSetup对象,所以假设工作簿是打开的,请尝试以下操作:

Sub cpyPS() Dim wsFrom As Worksheet, wsTO As Worksheet Set wsFrom = Sheets("From") Set wsTO = Sheets("To") With wsTO.PageSetup 'there are nearly 50 properties .AlignMarginsHeaderFooter = wsFrom.PageSetup.AlignMarginsHeaderFooter .BlackAndWhite = wsFrom.PageSetup.BlackAndWhite .BottomMargin = wsFrom.PageSetup.BottomMargin ' ' .LeftMargin = wsFrom.PageSetup.LeftMargin ' ' .Orientation = wsFrom.PageSetup.Orientation ' ' .PaperSize = wsFrom.PageSetup.PaperSize .RightHeaderPicture.Filename = wsFrom.PageSetup.RightHeaderPicture.Filename .RightMargin = wsFrom.PageSetup.RightMargin ' ' .TopMargin = wsFrom.PageSetup.TopMargin ' ' .Zoom = wsFrom.PageSetup.Zoom End With End Sub 

这里提供了需要考虑的所有房产列表。

没关系,也许把它写成一个函数,然后发回给所有人使用?

您可以随时复制整张表格,并将其重新命名,如果这对您是可行的。 这些房产将被“穿越”。