2012-03-21 22 views
0

這是我的問題,我將幻燈片插入到具有不同背景的演示文稿中,但我不知道如何在新背景上「隱藏背景圖形」滑動。到目前爲止,我的代碼如下所示:以編程方式將新幻燈片插入到演示文稿時隱藏背景圖形

 //Create a background color 
     Color myForegroundColor = Color.Aqua; 
     int oleColor = ColorTranslator.ToOle(myForegroundColor); 

     //Set the background color of teh slide 
     lPresentation.Slides[2].FollowMasterBackground = MsoTriState.msoFalse; 
     lPresentation.Slides[2].Background.Fill.Background(); 
     lPresentation.Slides[2].Background.Fill.ForeColor.RGB = oleColor; 
     lPresentation.Slides[2].Background.Fill.Solid(); 

回答

0

你也想使用.NET時.DisplayMasterShapes設置爲false

而作爲好奇,一個問題,是不是真的有必要重複所有lPresentation.Slides [2]每行的東西?

或者,你可以這樣做:

With lPresentation.Slides[2] 
    .Property = Value 
    .OtherProperty = OtherValue 
    .Etc = "And so forth" 
End With 

在VBA/VB,這樣做會被認爲是最佳做法...打字少,錯誤,更具可讀性和實際有點快這麼少的機會執行。考慮到我從來沒有在.NET中看到這樣做,我猜測它不是包的一部分。

+0

使用C#時,它是必需的,它與.Net無關。 'VBA/VB!= C#'(或任何不等於運算符的語言)。 – user7116 2012-03-21 14:09:56

+0

>> VBA/VB!= C#那裏沒有問題。可惜所有打字。 ;-) – 2012-03-21 23:40:08

+0

不錯,它解決了問題,謝謝!當然你可以在C#中使用「With」我只是不喜歡它嘿 – Ptimus 2012-03-27 11:30:13

相關問題