Save Userform Data for Each Shape

Started by prasanna2j, October 20, 2011, 01:11:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

prasanna2j

Is there any way I can save a Userform for each Shape so I can edit the its data whenever need.

I have linked the Master Stencil with Userform.Show.

Is there any way to retrieve all the data for that instance of Userform when called again?


Thanks for your time.

Jumpy

I guess on UserForm.Show you have to look which shape is selected and then retrieve the needed values VBA and place them in  the form. I guess you are talking about more then only ShapeData (as a dialog for that already exists)?

aledlund

This really isn't a 'newbie' question because it can get pretty deep pretty fast. It starts with examining a shape for it's 'content' and then goes to "retrieve all the data for that instance of Userform". The reason I highlight your question is that it does not ask to reexamine the original shape, but rather examine the data at that point in time (which has an underlying assumption that the data may have changed). Is that really what you want?
al

prasanna2j

Jumpy,

To explain my query, say I want to have a shape1 with a name as UNIT1 and another shape2 as UNIT2.

I use a Userform textbox for that. I click on shape1 and give it UNIT1 as a name. When I click on Shape2, the Blank userform shows up and I give it UNIT2 as a name.

Is there any way that if I click again on Shape1, I can retrieve UNIT1 as its name for maybe editing it or just viewing, instead of having another blank userform for my service.

prasanna2j

Al,

Yes, I want to examine (edit) the data that was previously assigned to that shape via the userform. Although, no change in data has taken place, its me who will change it as needed.

Jumpy

Maybe you should show some code u use, to show the UserForm and/or how you place the values entered in the UserForm in the shape.

prasanna2j

Jumpy, Al,

I kind of figured this out, thanks to the questions u raised. I used excel to store the userform values against the Shape IDs.

When I click a used shape, this code goes through the excel sheet, looks for the Shape ID and pastes its respective values to the userform before showing it; Else, it shows a blank one.


Dim shpobj as Visio.Shape
loInputtable as Excel.workbook.worksheet.listobjects("InputTable")

For i = 1 To loInputTable.ListRows.Count
   
'   If ActiveWindow.Selection.Count = 0 Then
'        MsgBox ("select a shape with connections")
'        Exit Sub
'    Else
        Set shpobj = ActiveWindow.Selection(1)
'    End If
   
    If loInputTable.ListColumns(1).DataBodyRange(i).Value = shpobj.ID Then
   
       Userform1.txtTag.Value = loInputTable.ListColumns(2).DataBodyRange(i).Value
       
        Userform1.Show
       
        Exit Sub
       
    ElseIf loInputTable.ListColumns(1).DataBodyRange(i).Value = "" Then
   
        Userform1.Show
       
        Exit Sub
   
    End If

Next i

aledlund

be aware that shape.id is only unique to a page (you can have other shapes with the same id on different pages). This project may add value to what you're trying to do
http://visguy.com/vgforum/index.php?topic=2298

al

prasanna2j

Thanks for the heads-up Al. I will use that info.