2014-12-04 21 views
0

每次我在某些工作簿上看到代碼時,我都會在頁面的頁腳中找到雙重路徑。尤其是因爲我確實在這裏指定中心頁腳應該是空的,這實際上是非常厭煩的。任何人都可以告訴我爲什麼這個代碼生成頁腳內容或.leftfooter複製.centerfooterExcel VBA組成自己的頁腳

Sub Print_Setup() 
Dim CurrentWB As Workbook 
Dim Page As Worksheet 

Set CurrentWB = ActiveWorkbook 
For Each Page In CurrentWB.Worksheets 
    With Page.PageSetup 
     .CenterHorizontally = False 
    'Make sure there is room to make notes on the sides of the page 
    'Page Margins 
     .TopMargin = 0 
     .LeftMargin = 14.4 
     .RightMargin = 0 
     .BottomMargin = 18 
    'Footer 
     .FooterMargin = 0 
     .RightFooter = "&8Printed &D: &P of &N" 
     .CenterFooter = "" 
     .LeftFooter = "&8&Z&F[&A]" 
    End With 
Next Page 
End Sub 

回答

1

我跑我的系統(Windows 7,Excel 2003中)多次在這個宏,並沒有發現相同的行爲。

我發現的一件事是,如果你有一條漫長的道路,它可以佔據頁面底部或頂部的很多房地產。

你運行的是什麼版本的Excel,BTW?

+0

感謝您的pormt響應,我在Win7上使用Excel 2010。 – sgp667 2014-12-04 17:12:47

+0

如果您將頁腳設置爲空值並執行打印預覽,該怎麼辦?你有同樣的結果嗎?另一種選擇是先將它們設置爲空,然後將它們設置爲所需的值。 你在做其他頁面設置的東西嗎? – asylumax 2014-12-04 17:22:18

+0

是的,我設置了無效。不知道爲什麼這個工作,但它確實 – sgp667 2014-12-04 17:37:18