2011-07-07 44 views
1

最近我們升級了一個我們的PowerPoint插件,以支持2007年和2010年。我們能夠移植的大多數項目沒有問題。我們遇到的一個問題是,使用插件創建表格或形狀時,縮進不起作用。PowerPoint編程:標尺邊距水平縮進不起作用?

爲如:同一個表被用正確的縮進下降在2003年,但同樣的事情沒有得到壓痕添加到使用2007

下面

當是代碼片段,允許縮進:

With PropertyValues.ObjShape.Table.Cell(row, col).Shape.TextFrame.Ruler 
       For rulerCount = 0 To 5 
        .Levels(rulerCount).FirstMargin = rulerFirstMargin(rulerCount) '.LeftMargin = rulerLeftMargin 
        .Levels(rulerCount).LeftMargin = rulerLeftMargin(rulerCount) 'Left indent marker 
       Next rulerCount 
     End With 

任何想法,爲什麼這是行不通的?

我閱讀下面的線程太多,但並沒有太大的幫助http://answers.microsoft.com/en-us/office/forum/office_2007-customize/why-shapetextframerulerlevelsi-cant-set-the-bullet/9eac3e46-b13b-433e-b588-216ead1d9c1a?tab=AllReplies#tabs

更新的代碼:

PropertyValues.ObjShape.Table.Cell(row, col).Shape.TextFrame.TextRange.Text = "N/A" 
      With PropertyValues.ObjShape.Table.Cell(row, col).Shape.TextFrame 
       'Dim rulerCount As Short 
       For rulerCount = 1 To 5 
        .Ruler.Levels(rulerCount).FirstMargin = 10 * rulerCount 'rulerFirstMargin(rulerCount) '.LeftMargin = rulerLeftMargin 
        .Ruler.Levels(rulerCount).LeftMargin = 20 * rulerCount 'rulerLeftMargin(rulerCount) 'Left indent marker 
       Next rulerCount 
      End With 
      PropertyValues.ObjShape.Table.Cell(row, col).Shape.TextFrame.TextRange.Text = text 

回答

1

FWIW,在2007年和起來,你現在可以有多達9尺的水平,而不是5如在耳機版本中。但是你的代碼應該是原樣。下面是一個簡化版本,做一個表中的任意單元格(2,2)工作:

Dim oSh As Shape 
Dim x As Long 
Set oSh = ActiveWindow.Selection.ShapeRange(1) 

With oSh.Table.Cell(2, 2).Shape.TextFrame 
    For x = 1 To 9 
    .Ruler.Levels(x).LeftMargin = x * 10 
    .Ruler.Levels(x).FirstMargin = x * 20 
    Next 
End With 

你可能會碰到的另一件事是,你可以將某些類型的格式(包括標尺設置)所有你喜歡;如果沒有文字在您要應用的級別,PPT就不會吠叫。它會忽略你。您的設置將不起作用。有時你需要檢查文本,如果沒有的話,提供一些文本(真實世界中極不可能的東西),然後刪除不可能的文本的所有實例。

醜。是。爲線索

Sub test() 

Dim oSh As Shape 
Set oSh = ActiveWindow.Selection.ShapeRange(1) 
Dim RulerCount As Long 
Dim sTemp As String 

sTemp = "@#$%" ' dummy text 

With oSh.Table.Cell(2, 3).Shape.TextFrame 

    For RulerCount = 1 To 5 
     .TextRange.Paragraphs(RulerCount).Text = sTemp & vbCrLf 
     .TextRange.Paragraphs(RulerCount).IndentLevel = RulerCount 
    Next 
    For RulerCount = 1 To 5 
     .Ruler.Levels(RulerCount).FirstMargin = 10 * RulerCount 'rulerFirstMargin(rulerCount) '.LeftMargin = rulerLeftMargin 
     .Ruler.Levels(RulerCount).LeftMargin = 20 * RulerCount 'rulerLeftMargin(rulerCount) 'Left indent marker 
    Next RulerCount 
End With 


End Sub 
+0

史蒂夫感謝:

在這裏,我們試圖格式化每個縮進級別之前添加文本,並設置縮進級別。但請檢查上面更新的代碼。它也沒有工作。有什麼具體的我們必須做的。除此之外,如果我調試並看到左邊的價值..它說價值超出範圍?但即時設置值0,36,72,108,144 – Aneef

+1

檢查我的帖子的編輯版本;這應該有所幫助。 –

+0

嗨史蒂夫,謝謝你會檢查這一點,並更新你 – Aneef