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.
The TextBox is a "control" in the userform, and has properties, methods, and events associated with it. If a TextBox is named, "TextBox1", for example, then TextBox1.Value would refer to the text string that is shown in that TextBox.
The good news here is that this is a VBA thing, not specifically a CorelDRAW thing. So, you're not limited to CorelDRAW-specific references when trying to look for information and examples related to this.
I'm not trying to be cute by not recommending a specific reference for this; I just don't know of specific resources to recommend at this time. I've looked at a lot of different sources over the years as I muddled my way through this sort of stuff myself.
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.
Ah, sorry, I overlooked the fact that you're running X6.
I agree about the many benefits of learning things along the way, and that's the way I've approached a lot of this sort of stuff myself. New projects benefit from your ever-growing box of tools.