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
  • 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.

No Data