VariantString into Constant

P

PiusSchuler

Within a UserForm I go the user to select a LineWidth, which then is
saved in a registry key e.g. wdLineWidth300pt. This value then should
be used to be asigned within a Word macro to assign the LineWidth. The
problem is, that I do not get back a constant but a VariantString. Is
it possible to convert the string bach to the constant?

With .Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleSingle
.LineWidth = GetSetting("TLKey", "Setting", "LineWidth")
.Color = wdColorAutomatic
End With
 
J

Jonathan West

PiusSchuler said:
Within a UserForm I go the user to select a LineWidth, which then is
saved in a registry key e.g. wdLineWidth300pt. This value then should
be used to be asigned within a Word macro to assign the LineWidth. The
problem is, that I do not get back a constant but a VariantString. Is
it possible to convert the string bach to the constant?

With .Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleSingle
.LineWidth = GetSetting("TLKey", "Setting", "LineWidth")
.Color = wdColorAutomatic
End With

The setting is being saved in the registry as a string (presumably using the
SaveSetting command), so you have to convert it back to a number before
applying the value back to the LineWidth property.

Try this.

With .Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleSingle
.LineWidth = CInt(GetSetting("TLKey", "Setting", "LineWidth"))
.Color = wdColorAutomatic
End With

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
P

PiusSchuler

Thanks for this prop, but does not work - as GetSetting("TLKey",
"Setting", "LineWidth") in this case delivers not a numeric expression
but the string "wdLineWidth300pt".
I changed my userform to save the numeric values of the VBAconstans.
now it wirks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top