Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: mmulvenna on February 27, 2009, 10:26:58 PM

Title: Shape Sheet Values from WIndows registry
Post by: mmulvenna on February 27, 2009, 10:26:58 PM
I have a user cell called user.part_name

The value of this cell is stored in the windows registry.

I have vba function to retrieve the value from the registry and it works fine when I run it from the vb code.

How do run the function from the shapesheet cell.

I have tried to set user.part_name = runaddon(projectname.modulename.function, param1, param2) but it does not retrive the value. I have also tried the callthis function with the same results
When I view the value rather than the formula it show "False" as the value

As alwasy any help is appreceiated.

Old man Mike :D
Title: Re: Shape Sheet Values from WIndows registry
Post by: mmulvenna on February 28, 2009, 12:35:43 PM
Okay here is an update. the user.part_name has this formula =CALLTHIS("GetJTFRegistry(""Part A"", ""\Toekick Part Names\Base"")")


If I remove the passed parameters in the cell formula, I get the message box
this is the VBA codePublic Function GetJTFRegistry(optional registryname, Optional tree) As String
    MsgBox "Got Here"
    Dim answer
    answer = GetRegistryValue(HKEY_CURRENT_USER, "Software\JTFinneran\Frameless Cabinets" + tree, registryname, REG_SZ)
    GetJTFRegistry = answer
End Function


This is the code that does the initialize of form fields in the vbs code that works just fine.Private Sub UserForm_Initialize()
' these fields are the part names contained in the windows registry

    txtbaseparta = GetJTFRegistry("Part A", "\Toekick Part Names\Base")
    txtbasepartb = GetJTFRegistry("Part B", "\Toekick Part Names\Base")
    txtbasepartc = GetJTFRegistry("Part C", "\Toekick Part Names\Base")
    txtbasepartd = GetJTFRegistry("Part D", "\Toekick Part Names\Base")
    txtbaseparte = GetJTFRegistry("Part E", "\Toekick Part Names\Base")
    txtbasepartf = GetJTFRegistry("Part F", "\Toekick Part Names\Base")


As always any help is appreceiated
Title: Re: Shape Sheet Values from WIndows registry
Post by: mmulvenna on February 28, 2009, 02:51:36 PM
Update 2

From the SDK

"The CALLTHIS function always evaluates to 0, and the call to procedure occurs during idle time after the recalculation process finishes. Procedure can return a value, but Visio ignores it. Procedure returning a value that Visio can recognize by setting the formula or result of another cell in the document, but not the cell that called procedure unless you want to overwrite the CALLTHIS formula."



So any ideas on how I can do this?

Guess I will try to put a formula in the scratch section to update the user.part_name cell. Do I use the SETF with something else? not quite sure i understand SETF and GETREF. Will do some digging..... :'( :'( :'(

Thanks Again
Mike
Title: Re: Shape Sheet Values from WIndows registry
Post by: Paul Herber on February 28, 2009, 07:07:00 PM
If you pass the cell reference to your VBA routine then the VBA can set the cell to the new value.

Title: Re: Shape Sheet Values from WIndows registry
Post by: mmulvenna on February 28, 2009, 11:06:05 PM
Thanks, I will give it a shot. Thanks for the recommendation.