S
Steven M (remove cola to reply)
I have an outside application that reads Excel files, but there is
something causing an error. I tracked it to a text box that contains
something that is not exactly text. I could probably get rid of the
text box and puts its contents directly into the underlying cells, but
I would rather modify the text box using VBA. (The first file has 35
worksheets, each with several text boxes and there might be more
later.)
The code I have written cycles through all objects on all worksheets.
I can access the text in a particular text box two different ways:
Worksheets(j).Shapes(i).Select
myText = Worksheets(j).Shapes(i).AlternativeText
thisText = Selection.Text
However, when I run it, they give two different values:
myText = "VALVES"
thisText = "¶ VALVES"
The character that I give as a ¶ is actually ASCII code 10, or
NewLine.
I want to cycle through all the boxes and delete any leading space and
other characters that are not visible characters from each box.
However, he only way that I see to assign text to the object when I
select it this way is with the AlternativeText property. But that
method doesn't get rid of the NewLine.
And this statement gives an error:
Selection.Text = myText
Run-time error '1004':
Unable to set the Text property of the Range class.
Any ideas?
something causing an error. I tracked it to a text box that contains
something that is not exactly text. I could probably get rid of the
text box and puts its contents directly into the underlying cells, but
I would rather modify the text box using VBA. (The first file has 35
worksheets, each with several text boxes and there might be more
later.)
The code I have written cycles through all objects on all worksheets.
I can access the text in a particular text box two different ways:
Worksheets(j).Shapes(i).Select
myText = Worksheets(j).Shapes(i).AlternativeText
thisText = Selection.Text
However, when I run it, they give two different values:
myText = "VALVES"
thisText = "¶ VALVES"
The character that I give as a ¶ is actually ASCII code 10, or
NewLine.
I want to cycle through all the boxes and delete any leading space and
other characters that are not visible characters from each box.
However, he only way that I see to assign text to the object when I
select it this way is with the AlternativeText property. But that
method doesn't get rid of the NewLine.
And this statement gives an error:
Selection.Text = myText
Run-time error '1004':
Unable to set the Text property of the Range class.
Any ideas?