PDA

View Full Version : Powerpoint 2007


Peter Busfield
17th August 2006, 11:22 PM (23:22)
I have written a program in VB.NET that connects to Powerpoint. The below code works when connected to PowerPoint 2000, XP (2002) and 2003, but does not work in 2007. To test this, I have removed all references to older versions of PowerPoint ie 9, 10 and 11, and added a reference to Powerpoint 2007 to force VB to use the version 12 object model. I have stepped through the VB.NET code and have confirmed that the Presentation Object I am using is version 12.

The code is:

Shp2 = Sld.Shapes.AddTable(1, iColumns, iLEFT, siTop, Sld.Master.Width - (iLEFT * 2), 380)


With Shp2.Line
.ForeColor.RGB = gCOLOR_BLUE_DARK
.Weight = 0
End With

The Sld object is declared as a Microsoft.Office.Interop.PowerPoint.Slide
The Shp2 object is declared as a Microsoft.Office.Interop.PowerPoint.Shape

The Sld object has been set to an instance of one of my slides in the current presentation. The AddTable command works fine.

It errors
All I am trying to do is change the Line colour of a table that I have created.

When checking the RGB property in the watch window it says:

<error: an exception of type: {System.ArgumentException} occurred>

Does anyone have any ideas on how to change the Line Colour of a table (ie the border colour of the Table)

Thanks for any help in advance.

--
Regards,

Peter


=== This is an automatically generated message ===

This is my first post. My Welcome thread is here. Please post all my welcome messages there.

=== This is an automatically generated message ===

Adam Spriggs
18th August 2006, 09:52 AM (09:52)
First of all, I'm not a .NET programmer.

Where is gCOLOR_BLUE_DARK defined? Is it a system variable?

Should it be something like this?

With Shp2.Line
.ForeColor.RGB = RGB(128, 128, 128)
.Weight = 0
End With

(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbapp11/html/ppproLine1_HV05192983.asp)

Peter Busfield
20th August 2006, 07:46 PM (19:46)
Sorry Adam,

The variable gCOLOR_BLUE_DARK has been defined globally as 6684672. That syntax that you have used for the RBG is close, but the problem actually lies in the RGB property of the object model itself. The code I have shown here actually works under the versions 9 to 11 object model of Powerpoint, but for some reason the property returns an error in v12 (2007). I can't even retrieve the value, let alone set it. So maybe it is a issue with the Beta version of Office and Microsoft haven't implemented everything in the object model yet. Does anyone else know if this is the case or how to fix it?