View the value of a custom property

Hello

 

I'm currently making a macro, I'd like to simply display the value of a custom property in the userform as text.

 

Anyone know how to do that?

 

Thank you all and have a good day!

Hello

 

You need to create a variable that will retrieve your property:

 

Example with my code property:

 

CODE = swRefDoc.GetCustomInfoValue("", "code")

 

Then, simply display CODE in the userform!

I don't know how to display it exactly. There must be a code? Print or something?

 

(The goal is to have it in a textbox)

It doesn't work to simply write:

Textbox1 = CODE

When initializing the userform, you must assign the default text of the textbox with

 

.value = CODE

 

By declaring CODE in public, of course.

 

Example:

 

Private Sub UserForm_Initialize()

With Me.NameTextBox

. Value = CODE

. SetFocus

. SelStart = 0

. SelLength = Len(. Text)

End With

End Sub

Sorry but I don't understand.

What is your textbox called?

Dison textbox1, then you need to set the default text like this textbox1.value = CODE where CODE is the custom property.

 

And you have to put this in a special sub that initializes your UserForm, either: 

 

Private Sub UserForm_Initialize()

Me.TextBox1.Value = CODE

End Sub

 

But in order for your CODE variable to be read in another sub, don't forget to declare it in Public CODE at the very beginning of your program.

 

Is it clearer?

Do you have a complete piece of code to offer me?

 

My property is "DW_NUM"

 

In summary I would simply like to display in a texrbox of a userform of a solidworks macro, the value of "DW_NUM" (which is for example: DW-505).

 

The text should load itself when the macro starts if possible.

 

Thank you!

Send your file with your macro!

It works, I'm looking to do it this lunchtime!

Here!


lynkoa.zip

I don't see where it's stuck...?