Author Topic: Save Userform Data for Each Shape  (Read 4502 times)

0 Members and 1 Guest are viewing this topic.

prasanna2j

  • Jr. Member
  • **
  • Posts: 23
Save Userform Data for Each Shape
« on: October 20, 2011, 08:11:36 AM »
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

  • Hero Member
  • *****
  • Posts: 1061
Re: Save Userform Data for Each Shape
« Reply #1 on: October 20, 2011, 08:20:32 AM »
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

  • Hero Member
  • *****
  • Posts: 1412
Re: Save Userform Data for Each Shape
« Reply #2 on: October 20, 2011, 08:31:57 AM »
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

  • Jr. Member
  • **
  • Posts: 23
Re: Save Userform Data for Each Shape
« Reply #3 on: October 20, 2011, 08:36:53 AM »
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

  • Jr. Member
  • **
  • Posts: 23
Re: Save Userform Data for Each Shape
« Reply #4 on: October 20, 2011, 08:41:42 AM »
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

  • Hero Member
  • *****
  • Posts: 1061
Re: Save Userform Data for Each Shape
« Reply #5 on: October 20, 2011, 09:53:16 AM »
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

  • Jr. Member
  • **
  • Posts: 23
Re: Save Userform Data for Each Shape
« Reply #6 on: October 21, 2011, 04:18:34 AM »
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

  • Hero Member
  • *****
  • Posts: 1412
Re: Save Userform Data for Each Shape
« Reply #7 on: October 21, 2011, 06:07:39 AM »
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

  • Jr. Member
  • **
  • Posts: 23
Re: Save Userform Data for Each Shape
« Reply #8 on: October 21, 2011, 09:21:05 AM »
Thanks for the heads-up Al. I will use that info.