getting the value of a textbox VBA Macros

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 ShapeRange
Dim lngCounter As Long

Const space_dist As Double = 0.5
Set sr = ActiveSelectionRange
If sr.Count > 1 Then
sr.Sort ("<")
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

MsgBox "Must have two or more objects selected.", vbInformation
End If
End 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.


No Data
  • 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: