如何将pagesetup复制到不同的工作簿?

时间:2014-03-21 16:28:03

标签: vba

我是两本工作簿。我需要将pagesetup从wb2复制到wb1。

With wb1.sheets("test") .pagesetup.footermargin = wb2.sheets("xxx").pagesetup.footermargi End

1 个答案:

答案 0 :(得分:1)

试试这个:

Sub savefooter()
Dim twb as workbook
Dim wb2 as workbook
Dim a as variant
Application.DisplayAlerts = False
Set twb = ThisWorkbook
a = twb.Sheets("Sheet1").PageSetup.FooterMargin
Set wb2 = Workbooks.Open("C:\b.xlsx") ' set path to where your second wb is
wb2.Sheets("Sheet1").PageSetup.FooterMargin = a
wb2.Save
wb2.Close
Application.DisplayAlerts = True

End Sub