Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default C# adding textbox to excel sheet

Anytime I try to add a textbox to my excel sheet in the following manner an
exception is generated.

Excel.Shape textbox;
textbox =
(Excel.Shape)excelWorksheet.Shapes.AddFormControl( Excel.XlFormControl.xlEditBox, cellx, celly, cellwidth, cellheight);

What am I doing wrong?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default C# adding textbox to excel sheet

This worked for me, but it's in VB.. But I believe it shouldn't be too hard
to port to C#.


Dim xlApp As New Excel.Application
Dim xlWb As Excel.Workbook
Dim sht As Excel.Worksheet
Dim tb As Excel.OLEObject

xlWb = xlApp.Workbooks.Add
With xlWb.Sheets("Sheet1")
sht = xlWb.Worksheets("Sheet1")
tb = sht.OLEObjects.add(ClassType:="Forms.TextBox.1",
Link:=False, _
DisplayAsIcon:=False, Left:=120, Top:=48, Width:=132,
Height:=53.25)
End With

xlWb.SaveAs("C:\TEMP\Sample.xls")

xlWb.Close(False)
xlApp.Quit()



--
Hope that helps.

Vergel Adriano


"SkyKid" wrote:

Anytime I try to add a textbox to my excel sheet in the following manner an
exception is generated.

Excel.Shape textbox;
textbox =
(Excel.Shape)excelWorksheet.Shapes.AddFormControl( Excel.XlFormControl.xlEditBox, cellx, celly, cellwidth, cellheight);

What am I doing wrong?

Reply
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
Adding shape-type textbox into excel chart sheet [email protected] Excel Programming 2 August 20th 06 08:26 AM
Textbox changes position on a copied excel-sheet Hanspeter W. Excel Discussion (Misc queries) 0 July 1st 06 09:41 PM
Display a textbox embedded in the Excel sheet Tom Shi Excel Programming 1 June 2nd 05 09:32 PM
Textbox adding problem Todd Huttenstine[_3_] Excel Programming 11 February 10th 04 09:51 AM
Textbox on excel sheet do not update with VBA Ben Joiner Excel Programming 4 November 6th 03 11:07 AM


All times are GMT +1. The time now is 08:10 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"