LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default C#: Adding OLEObject--how to set object properties?

I used the following line to add a label (or textbox, etc.) to my worksheet,
and I can see it in Excel.

Excel.OLEObject ole =
((Excel.OLEObjects)wsTemplate.OLEObjects(Missing.V alue)).Add("Forms.Label.1",
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, 15, 15, 100, 20);

The problem is that it just says "Label1" for the text. How can I go about
changing it and the font as well? I can't figure out how to cast the
ole.Object to anything which is what I think I need to do.

I've see lots of VBA code that just uses "With" as below, but can I do
something similar in C#?

Dim Lbl As OLEObject
Set Lbl = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label .1",
Link:=False, _
DisplayAsIcon:=False, Left:=232.5, Top:=241.5, Width:=72, Height:=18)

With Lbl
.Name = "ttt"
.Object.Caption = "p.sub new control"
.Object.Font.Bold = True
.Object.BackColor = RGB(255, 0, 0)
End With

Any help would be appreciated.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object properties viewer DPassed Excel Programming 0 October 29th 07 04:05 PM
Error on fetching object in OLEObject syrhus Excel Programming 0 March 2nd 05 03:15 PM
Get OLEObject.Object with Csharp Bragadiru Excel Programming 0 November 3rd 04 08:22 AM
Word Art Object properties in VBA Arnie[_5_] Excel Programming 0 March 7th 04 03:55 AM
iterating through all properties of an object Barney Fife Excel Programming 4 August 22nd 03 03:18 AM


All times are GMT +1. The time now is 09:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"