Width of specific text in pixels

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
I know I've seen this, a combobox that autoadjustes itself to the longest entry in there, but I don't remember where I saw that ! What I need is find out how "long" a text (In a specific font name, size and style) is, in pixels, so i can set the column width to that... any ideas ?
 
Nice posts guys. I'm still going to have a crack at this one for myself as well though. I appreciate the HDC advice and I'm going to analyse both of your contributions.

What I'm after is a textbox, or maybe even a cell that automcatically resizes when the typed text wraps to a new line.
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
On 2002-08-24 19:35, Mark O'Brien wrote:
Nice posts guys. I'm still going to have a crack at this one for myself as well though. I appreciate the HDC advice and I'm going to analyse both of your contributions.

What I'm after is a textbox, or maybe even a cell that automcatically resizes when the typed text wraps to a new line.

Mark if your going to do this then your need
the Class name of the sheet and possibly the caption to this.
As you probably know all the Objects in an Excel application have there own ClassIds > ClassName. If you use Toms & Juans code then your'll need the handle to the Objects, to get the handle your'll need the ClassName.
For the sheet it is EXCEL7.
BTW....look @ the Name Box down List!!
Ever noticed that it doesn't display the full text when you click on this and you have a lonnng Defined name (Annoying)...well
heres a prime one to change....see if you can change this, and we can compare notes.

Do you want the classname for this ? :)
BTW there are actually 3 diff classes to look @ here.... concerning the dropdownclick, Editmode & CB selection..

_________________
Kind Regards,<font size=+2><font color="red"> I<font color="blue">van<font color="red"> F M</font color="blue">oala</font><font size=1> From the City of Sails
image.gif

This message was edited by Ivan F Moala on 2002-08-24 21:59
 
Upvote 0
Ivan... you really need to get off the computer now... :wink: the first link I found can handle the "dropped down width" of a combobox quite nicely, so, if you know the class name for that, you could probably use that code to fix Excel ! Anyway, I was missing you on this thread !
 
Upvote 0
On 2002-08-24 21:59, Juan Pablo G. wrote:
Ivan... you really need to get off the computer now... :wink: the first link I found can handle the "dropped down width" of a combobox quite nicely, so, if you know the class name for that, you could probably use that code to fix Excel ! Anyway, I was missing you on this thread !

Yes, thats a good link, I use this to have a look...time to go :)
 
Upvote 0
Want to make some bucks? If you could create the ultimate API wrapper for extending Excel, I would buy it. There seem's to be a developer's market and I'm wondering why there is not a product out there for these types of limitations?
 
Upvote 0
On 2002-08-24 22:58, TsTom wrote:
Want to make some bucks? If you could create the ultimate API wrapper for extending Excel, I would buy it. There seem's to be a developer's market and I'm wondering why there is not a product out there for these types of limitations?

Hi Tom,
yeah good idea...as with the problem above with the Name Box dropdown list been limited in width....I tried to get this going but I think I need to look @ SubClassing and intercept the Event for excels DropdownClick for the Name Box....
What other Xl annoyances are there ??
Should make a list and see what can be done IF at all ?? make it into a Dll file, I know that you have done some work here :)
 
Upvote 0
Well Ivan.

I'm pretty much in the infancy stage when it comes to Office development and programming for that matter. Even so, I have run into several situations where I have been frustrated a bit.

Here are some of the things I would like to do if I could without the need for a seperate developement tool...

Create a Property Pages class for some of the more popular controls in VBA. Beef up your ability to set properties in the VBA-VBE for various controls which fall short of what's easily available in VB. The properties seem to be available if you really know your way around the API which I don't.

Make it easier to use control arrays. As I know it, it's a pain.

The ability to imbed an Excel worksheet(not the Office Spreadsheet control) within an Excel worksheet. I don't know if this is possible or not.

There are others as well. I'll jot them down when the come to me.

I'm probably out of bounds in my ignorance, but it sounds like fun!

Tom
 
Upvote 0
Hi Mark.
That sounds familiar. Comes with Visual Studio(VisC maybe?)I think. I have Visual Studio but only have VB installed. What can I do with the utility?
Tom
 
Upvote 0
Yeah, it comes with Visual Studio. I don't use it properly I suppose, but basically you run Spy++ and it shows you details of everything that is currently running. i.e. from class names, all the way to events that have been raised for every individual object. As I say, I don't use it properly, if memory serves, you can tell it to keep an eye on specific things. I've only ever used it to get classnames. (even then, only classnames that a little utility I put together fails to gather)
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top