2012-09-05 67 views
0

我嘗試從Excel VBA中設置單詞表格的邊框。許多網站建議如下:從Excel VBA中設置單詞表格邊框

wrdTable.Borders(wdBorderTop).LineStyle = wdLineStyleSingle 

但我得到一個錯誤(該集合的請求的成員不存在),而嘗試它。不過,我可以使用下面的代碼帶來的內邊框:

wrdTable.Borders(xlDiagonalUp).LineStyle = xlContinuous 

同樣地,我嘗試:

wrdTable.Borders(xlEdgeTop).LineStyle = xlContinuous 

帶來頂級的邊界,但我得到對角線。我如何在我的單詞表中應用邊界(內部和外部邊界)?我使用Office 2007的

回答

4

這些文章將讓你在正確的軌道上:

http://www.shaunakelly.com/word/formatting/border-basics.html

http://www.shaunakelly.com/word/styles/borders-in-table-styles.html

假設你wrdTable已正確設置爲表對象MSWORD的文檔中,你有一個幾個選項:

wrdTable.Borders.Enable = True 

將此設置爲True set的對象的b爲與此對象的當前默認邊框屬性相同的線條樣式和線寬。

否則準則

  • 第一設置.LineStyle。
  • 只有.LineStyle不wdLineStyleNone然後
    • 設置.LineWidth
    • 設置。顏色。

下面有一個更詳細的版本:

With wrdTable.Borders 
    .OutsideLineStyle = wdLineStyleSingle 
    .OutsideLineWidth = wdLineWidth075pt 
    .OutsideColor = wdDarkRed 
End With 

有關語法的附加參考,看到這個頁面:

http://msdn.microsoft.com/en-us/library/office/aa221392(v=office.11).aspx

(注意,我輸入驗證碼來自我的手機,所以它未經測試)

+0

如果在IDE中有良好的智能感知,這些小事情不會有太大的麻煩。任何關於所有對象和屬性列表的建議。 – chemicalkt

+0

出於興趣,你的意思是wdColorDarkRed而不是wdDarkRed? –

1

在「Microsoft Visual Basic」中選擇菜單「工具」 - >「參考」並激活「Microsoft Word xx.x對象庫」。 Then

wrdTable.Borders(wdBorderTop).LineStyle = wdLineStyleSingle 

將工作。

我也在尋找相同的功能幾個小時。