How to format text in the cell, so the end of text will be visible?

J

Jack

In visual basic:
When the textbox is smaller than the text, to display the last part of the
text I do:
txtWaveFile.SelStart = Len(txtWaveFile.Text)

How can I do the same for the particular cell?

I have tried:
moExcelWS.Cells(1, 2).Text.sellstart = Len(moExcelWS.Cells(1, 2).Text)

but that of course is wrong.

Jack
 
D

Dave Peterson

Maybe you can justify the text to the left?

But if there's something in the cell to the left, you won't see the leading
text.
 
J

Jack

I have tried that.
When I do:
moExcelWS.Cells(2, 3).Justify = 1
the displayed text stretches over the 3 next cells below in the same
column!!!!
and Excel displays message:
"Text will extend below selected range"

I need to display only end of the text in the cell and because I do
automation I do not want any Excel messages to pop up.
Jack
 
D

Dave Peterson

Try changing the horizontal alignment manually just to see if that works for
you.

If you record a macro when you do it, you'd see something like:

moExcelWS.Cells(2, 3).HorizontalAlignment = xlRight
 
J

Jack

That's work. Thank you.
But still I am not satisfied with the result.
I am thinking about a different approach.
The cell contains full path and the file name.
And I am doing Excel automation, so my code is visual basic application
which controls Excel sheet.
Perfectly, I would like to have the following:
1.
make column( or cell) width autofit and display only title of the file.
2.
Create invisible column (I presume that it is possible) with corresponding
cells, which will store the path to that file.

How can I do that?

Thanks,
Jack
 
D

Dave Peterson

I would think the first would be pretty difficult--unless you used a fixed width
font and made the columnwidth just wide enough to show the name of the file.

The second sounds easier. You can hide a column in excel.

Record a macro when you select a cell in the column to hide.
Format|Column|Hide

You'll end up with something like:

Range("E1").EntireColumn.Hidden = True


That's work. Thank you.
But still I am not satisfied with the result.
I am thinking about a different approach.
The cell contains full path and the file name.
And I am doing Excel automation, so my code is visual basic application
which controls Excel sheet.
Perfectly, I would like to have the following:
1.
make column( or cell) width autofit and display only title of the file.
2.
Create invisible column (I presume that it is possible) with corresponding
cells, which will store the path to that file.

How can I do that?

Thanks,
Jack
 
J

Jack

If I hide the column will the numbering of columns change?
I need the original columns numbers stay intact.
I wonder, maybe there is .tag property I can use instead of hidden column?
Jack
 
D

Dave Peterson

What did you see when you hid a column?

Maybe you could use a comment (Insert|Comment from the menubar)?


If I hide the column will the numbering of columns change?
I need the original columns numbers stay intact.
I wonder, maybe there is .tag property I can use instead of hidden column?
Jack
 
J

Jack

Dave, I cannot use menu bar.
I am doing automation from my vbasic application.
moExcelWS.Rows(1, 1).Insert.Comment = "text"
does not work.
Can you show me how, please?
And how to retrieve that comment?

Also, I've found .SmartTags property.
How to use that?
Thanks,
Jack
 
D

Dave Peterson

If you open excel and record macros while you're doing things, it may make your
development of you automation code go faster.

moExcelWS.cells(1, 1).AddComment text:="hi there"

And you'll see that moExcelWS.Rows(1, 1) won't work.

And open excel and use excel's help to search for SmartTags. I don't think that
this is what you want.


Dave, I cannot use menu bar.
I am doing automation from my vbasic application.
moExcelWS.Rows(1, 1).Insert.Comment = "text"
does not work.
Can you show me how, please?
And how to retrieve that comment?

Also, I've found .SmartTags property.
How to use that?
Thanks,
Jack
 
Top