Translation of stencils

Started by Lars-Erik, March 09, 2009, 06:49:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

d310gece

I am using VBA only for selecting all shapes and applying a data graphics to them. I was thinking that I can enter CalloutTargetRef function in shape sheet of callout master, so it would get the reference of shape to which it is attached. I will dig deeper into posibilities of this function, if its only for VBA then it's  no use for me.
I know what you mean, by saying, Setup template, but when I apply data graphics it uses only one Callout master to all of the shapes, that means that it makes formating of all callouts the same. The best way would be deleting or at least disabling, character section in callout master shape sheet. The only problem is that I can't find a way to do that  .... :)

d310gece

OK, back to translation thing :) CalloutTargetRef works with simple callouts, but I couldnt make it work with custom callouts or TextCallouts. All that data graphic thing became a deadend. I couldn't format values seperatly. So I started looking for another way. And found it  8) Now it's not perfect working but I am trying to make it work. ok, now about the idea.
I created a simple shape, linked data from excell, inserted text field with information from excel and added it document stencil. After that I added a VBA code to change the text field value in master. It works great, exept few things:
1. I had to make VBA on every page (easy part)
2. I cant add info in master shape sheet call Fields.Value through VBA(Type mismatch error when trying to set value to Prop.Row2), so I add a number in user defined cells and Fields.Value is calculated using if. At first sight it looked ok, but I noticed that values are not refreshing until I make Fields.Value cell formula local not inheritant.
I think there are two solutions, either to find a way to remove the error or to make a formula local every time I drop or copy master.
Any suggestions?
I suppose that there is unnecessary things in my code but I am just a beginer so any comments are highly appreciated

Sub LT_click()

    Dim vsoMaster As Visio.Master
    Dim vsoMasterCopy As Visio.Master
    Dim vsoShape As Visio.Shape
    Dim vsoCell As Visio.Cell
    Dim vsoCell2 As Visio.Cell
    Dim PagsObj As Visio.Pages
    Dim PagObj As Visio.Page
'Changing master on all pages
    Set PagsObj = ActiveDocument.Pages
    For Each PagObj In PagsObj
        Set PagsObj = ActiveDocument.Pages
        ActiveWindow.Page = PagObj.Name
'Selecting master
    Set vsoMaster = Visio.ActiveDocument.Masters.Item("TextTranslate")
    Set vsoMasterCopy = vsoMaster.Open
'Selecting shape in master
    Set vsoShape = vsoMasterCopy.Shapes.Item(1)
'Selecting cell to change in shape's shapesheet
    Set vsoCell = vsoShape.CellsU("User.kalba")
    vsoCell = 1  //Cell value is added and in the ShapeSheet text field there is formula =GUARD(IF(User.Kalba=1,Prop.Row_2,IF(User.Kalba=2,Prop.Row_3,"No Data")))
   
Set vsoCell2 = vsoShape.CellsU("Fields.value")

    vsoCell2 = Prop.Row2 //here I get an error
   
'Closing and clearing master and shape
    Set vsoShape = Nothing
    vsoMasterCopy.Close
    Set vsoMasterCopy = Nothing
    Set vsoMaster = Nothing
   
Next
End Sub

d310gece

Made a correction of my code and now I am happy :) The only thing is that I have to maintain formula in Fields.Value inherited by master

Sub LT_click()

  Dim mst As Visio.Master
  Dim mstCopy As Visio.Master
  Dim shp As Visio.Shape
  Dim cell As Visio.cell
 
  Set mst = Visio.ActiveDocument.Masters.Item("TextTranslate")
  Set mstCopy = mst.Open
  Set shp = mstCopy.Shapes(1)

    'changes in text field
    Set cell = shp.Cells("Fields.Value")
    cell.Formula = "Prop.Row_2"  //If I need other information to be displayed, I change this value in macro for other button
    Set shp = Nothing

  mstCopy.Close

  Set mstCopy = Nothing
  Set mst = Nothing

End Sub

Now I can tell the whole idea of translating the shapes in drawing and how I made it.
I  created a simple shape, linked data from excell, inserted text field with information from excel and added it document stencil. After that I added a VBA code to change the text field value in master. My shape has ID (for auto linking data from excell), LT(Lithuanian translation), EN(English translation). I add shapes from master called TextTranslate in my drawing, format them the way I need. After that I add two command buttons for language changing and assign them the code from above. I press the button and voula :)
When I will need another language, I will add another collumn in excel and another button in drawing with a little change in code.
I use this to make multilanguage wiring diagrams. Whenewher I need to add another language, I don't have to make all the wiring diagram again. 

Yacine

This doesn't seem right.
Since you have a database driven solution, you'd better make the switch outside of visio, where it is much easier to handle.
You write that you don't know if there would come more languages in future.
So easiest would be to have a "textDisplayed" field, display it in the shapes and in the DB overwrite that field with whatever other data you need.

Just a thought ...
Yacine

d310gece

I've got your point. Your idea is great and I thought about that. The only problem is that in case of my absence in work other people might get confused :) So we declared the languages and I added all the needed columns and buttons. I understand thet this is not the best solution but it will do the job. Thanks for help and ideas