通知你,我使用Perl和Win32 :: OLE,但錯誤是Word VBA之一。當使用一系列單元而不是選擇時,wdBorderVertical爲什麼不存在?
使用Perl的的Win32 :: OLE模塊,我想在Word中創建一個表,並格式化它的某些元素。我創建了表(15 x 3)併成功創建了一個指向從(2,1)到(14,3)的單元格的範圍對象,即除頂部和底部行以外的所有單元格。
我然後設置OutsideLineStyle和InsideLineStyle並啓用邊界,但生成的表沒有在表中垂直邊框。整個表格周圍有一個邊框,並且行之間有邊框,但是沒有列邊框。
我試圖通過設置wdBorderVertical糾正這一點,但我得到的錯誤「的集合不存在的所需的成員。」我不知道爲什麼。
這裏是我的代碼:
$cells = $document->Range($table->Cell(2, 1)->Range->Start, $table->Cell(14, 3)->Range->End);
$cells->Borders->{OutsideLineStyle} = wdLineStyleSingle;
$cells->Borders->{OutsideLineWidth} = wdLineWidth150pt;
$cells->Borders->{InsideLineStyle} = wdLineStyleSingle;
$cells->Borders->{InsideLineWidth} = wdLineWidth150pt;
$cells->Borders->Item(wdBorderRight)->{LineStyle} = wdLineStyleSingle;
$cells->Borders->Item(wdBorderRight)->{LineWidth} = wdLineWidth150pt;
# The next two lines generate the error.
$cells->Borders->Item(wdBorderVertical)->{LineStyle} = wdLineStyleSingle;
$cells->Borders->Item(wdBorderVertical)->{LineWidth} = wdLineWidth150pt;
$cells->Borders->{Enable} = 1;
是否wdBorderVertical不存在的單元格範圍?我試圖做到這一點,而不使用選擇或循環,因爲它似乎(也許我錯了),範圍專門用於避免不必要的循環等,您可以使用多個範圍與單個選擇。
嗯..它會存在,如果我通過行循環? – romandas 2009-10-04 13:37:51
我不知道:(...我只是想研究一個答案,我只看到它適用於'Table's和'Item's .... – 2009-10-07 13:59:32
+1和接受。它不存在。 – romandas 2009-10-10 12:50:40