Hello, I'm trying to figure out how to take the value of what is entered into my textbox and put it into the code.
below is what I have currently:
Private Sub CommandButton6_Click()Dim sr As ShapeRangeDim lngCounter As Long
Const space_dist As Double = 0.5 Set sr = ActiveSelectionRange If sr.Count > 1 Then sr.Sort ("@shape1.com.sizewidth<@shape2.com.sizewidth") sr(1).TopY = sr.TopY For lngCounter = 2 To sr.Count sr(lngCounter).BottomY = sr(lngCounter - 1).TopY + space_dist Next lngCounter sr.AlignAndDistribute cdrAlignDistributeHAlignRight, cdrAlignDistributeVNone, cdrAlignShapesToLastSelected, cdrDistributeToSelection, False, cdrTextAlignBoundingBox Else MsgBox "Must have two or more objects selected.", vbInformation End IfEnd Sub
I want the highlighted number to be replaced with whatever is entered into this text box.
textbox is currently named "textbox1"
I've been trying to figure this out for weeks now. I've been having trouble finding anything through past discussions surprisingly.
I've also tried looking at other peoples' macro code that use textboxes and I guess I'm just not getting it.
I'm not experienced in code, but I've been dabbling for about a year now.
Something else you might consider, depending on exactly what your goals are...
In some cases, you might be able to write some code to do a specific part of a job, and then use some other existing tool(s) to do the rest. Those other tools might be native CorelDRAW tools, or they might be other macros.
Here's an example where I use one macro to arrange some shapes by width to set things up, then use my Space Between macro to create the desired spacing between them:
That's just an idea. I'm not trying to discourage you from doing the whole thing yourself.
If you're working with text, then my Space Between macro may not be suitable in all cases, because it works from the bounding box of the text. So, it can't ignore ascenders and descenders, and the spacing may not look good visually for text that has those.
Thank you for your input. I am working with text, and I did consider your space between macro, but I only have X6.
I got the code that I have so far from you to begin with, so thanks again for that. I'll see what I can find through excel vba tutorials. Part of me wants to figure it out myself anyway, because I learn other things along the way.