View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Lucas Lucas is offline
external usenet poster
 
Posts: 18
Default Data from sheet, through userform to text box on the sheet.

Than you for your reply NickH.

More info.

The problem is that data isn't placed in new text box on sheet. Ofcourse
textbox is created, everything about it is ok (format, lines, font) excapt
this that data isn't placed in it.

I use variable called "info" to transfer data from user form text box to
sheet text box. During code running i can see that variable info has proper
data but after executing:

Selection.Characters.Text = info or as you wrote (except use of variable
"info"):

Dim sp As Shape
Set sp = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHo rizontal, 30, 20,
40, 20)
With sp
.Name = "myBox"
.TextFrame.Characters.Text = info
End With

there is no data in text box in the sheet. There is no error info, code just
runs throught these lines bot there is no text in tb.

I noticed that there is no problem when there is less characters placed in
tb in sheet.
Then code works just fine.

I hope it helped.

Regards

Lucas




€˛NickH€¯ pisze:

Hi Lucas

I don't have enough information from your message to determine what is wrong.

When you say "some cases it works and some it doesn't", what is the nature
of the failure? Do you get an error; is the text missing from the added
textbox; is the textbox actually added at all?

You can insert the text in a single statement like this:

ActiveSheet.Shapes.AddTextbox(msoTextOrientationHo rizontal, 10, 10, 50,
30).TextFrame.Characters.Text = "1234"

You can also do it like this:

Dim sp As Shape
Set sp = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHo rizontal, 30, 20,
40, 20)
With sp
.Name = "myBox"
.TextFrame.Characters.Text = "1234"
End With

The advantage here is that you know exacly which shape you are manipulating
and you can name it as you want.

If this doesn't help, then please provide more details about the problem.

--
Nick


"Lucas" wrote:

Hello all,

I wrote program which uses data from sheet, than desplays data on the
userform and then prints data. User has to point which data should be
printed, data is transfered to text boxes on the particular sheet and then
printed. The point is that some data can't be put into textboxes on sheet
using vb. Ofcourse manually it is not a problem.

code that transfers data from userform to sheet looks like this:

info = UserForm5.TextBox1.Value

ActiveSheet.Shapes.AddTextbox(msoTextOrientationHo rizontal, Left1, top1,
Width1, height_box).Select

Selection.Characters.Text = info

For some reasons in some cases code works just fine and in some it doesen't.
At the begining i thought that it is connected with number of characters
that can be placed in text box but then, if the number of characters would be
to big, there will be no possibility of placing them manually. I'm sure that
data is every time in 'info' variable. Any ideas.

Thanks in advance.