Hello Experts,
I have this Visio 2003 problem which is "tearing me apart" for the last few days....
I am trying to draw an electronic system drawing (with multiple connections per system block to other system blocks). well I succeeded in doing this of course by creating my own shapes with multiple connections points.
What I want to do is to export this drawing to a database, to analyze the system architecture within this database and eventually get the system blocks and connections between these blocks in a database format.
My problems is as follows : The shape's "Name" field is not exported to the database. (nor it is found in the shapesheet)
I have been using the "Export to database" tool. when exporting the drawing to an Access database, I get the shapes and connection lines between them with information about the connection points (Begin,Y;Y ; End,X;Y) to other shapes. When trying you associate between the connection lines drawn and the shapes I am seeing a mismatch.
For example:
in the exported database I can find the connection line properties that contain the contention information (This comes is form the connection lines shapesheet)...
"BeginX ; Y" of a connection line are : "PAR(PNT(SubSystem.9!Connections.X2,Subsystem.9!Connections.Y2))"
and
"PAR(PNT(SubSystem.9!Connections.X2,SubSystem.9!Connections.Y2))" respectively.
meaning it is coming started at a shape named as "SubSystem.9!"
When looking for this "SubSystem.9" shape in the exported database i can't find it... , the only reference I have for the exported shapes is the "ShapeKey" field. and in the index of "SubSystem.9" shape in the exported database is not "9"..... . I can't find the "Name" in the exported database.
When marking each and every shape in the drawing and clicking on menu "Format->Special" I can see the information that I would like to get like "ID","Master","Type" and "Name" . but these are not exported to the database. If I would have the "Name" exported then I could associate between the a "ShapeKey" and "Name" and thus associate between the a connection line and the relevant shape.
Tried a workaround : I have tried to find a way to create a custom property like "Shape_Name" and using the "ShapeSheet", create a function that will assign the shape's "Name" to the "Shapes_Name" custom property, and this can be easily exported to the database..... but I could not find the function to do it.
It looks quite odd to me that you can access all of of the shapesheet information and properties but cannot get a shape's "Name".
I am puzzled... am I missing anything here ? how to do it ? how can I get the shape's "Name" being exported using the database export tool ?
I would appreciate if someone can help me.
Thanks,
Joseph D.
Unless you specifically name a shape via code, visio will assign one (that is unique only to the page it is on). In actuality it will assign two of them, Name and NameU. I haven't checked the export properties, but I suspect the NameU is in there.
You might check this out
http://msdn.microsoft.com/en-us/library/bb435962(office.11).aspx
you might check this out also
http://blogs.msdn.com/visio/archive/2006/07/27/679625.aspx
hth,
al
Hello al,
Thanks for your answer... but it does not help yet. please see below.
#1 - "Name" is no longer part of the shapesheet (as seen in this ref: http://books.google.co.uk/books?id=zZq_lBKcei0C&pg=PA126&lpg=PA126&dq=visio+shapesheet+name&source=bl&ots=z0molVHceq&sig=QnwNgRxnB17zZUv5I2MIj1bHn5M&hl=en&ei=4XXbSpWKGZHWmgOHqbXZDA&sa=X&oi=book_result&ct=result&resnum=9&ved=0CCAQ6AEwCA#v=onepage&q=name&f=false)
#2 - The above link says that "nameU" is part of the shapesheet on V2003. but ... I can't find "Nameu" in the shapesheet (visio 2003). where is it ? which section ?
#3 - tried to assign "=shape.nameu" and "=shape.name" and "=shape.NameID" to a custom propoerty but i get "error in formula".
#4 -page 88 of the above book suggets to use NameID.. OK.... so how do i get it as well ?
Thanks in advance.
JD
Thanks,
JD
I'm not sure how you are moving your 'names' to your custom properties. I tested the process with this macro code.
al
Public Sub myMacro()
Dim visApp As Visio.Application
Dim visPage As Visio.Page
Dim visShapes As Visio.Shapes
Dim visShape As Visio.Shape
Dim visShapeName As String
Dim visShapeNameU As String
Dim visShapeNameId As String
Set visApp = Application
Set visPage = visApp.ActivePage
Set visShapes = visPage.Shapes
'
'cycle through the shapes on the page
'
For Each visShape In visShapes
visShapeName = visShape.Name
visShapeNameU = visShape.NameU
visShapeNameId = visShape.NameID
ForceShapeProperty visShape, "myName", visShapeName
ForceShapeProperty visShape, "myNameU", visShapeNameU
ForceShapeProperty visShape, "myNameId", visShapeNameId
Next visShape
End Sub
'
' update custom property, if the property does not exist create it
'
Public Sub ForceShapeProperty(visShape As Visio.Shape, _
strProperty As String, _
strValue As String, _
Optional strAttrSet As String = "")
Dim visCell As Visio.Cell
Set visCell = Nothing
Dim strPropertyName As String
strPropertyName = "prop." & strProperty
Dim blnReturn As Boolean
If visShape.CellExists(strPropertyName, False) = False Then
blnReturn = AddCustomProperty( _
visShape, _
strProperty, _
strProperty, _
strProperty, _
, , , , , _
strAttrSet)
End If
Set visCell = visShape.Cells(strPropertyName)
SetCellValueToString visCell, strValue
End Sub
'***********************************************************************
'
' visio sdk code
'
'***********************************************************************
'
' from v2007 sdk, modified
'
Public Function AddCustomProperty(visShape As Visio.Shape, _
strLocalRowName As String, _
strRowNameU As String, _
strLabelName As String, _
Optional vsoPropType As VisCellVals, _
Optional strFormat As String, _
Optional strPrompt As String, _
Optional blnAskOnDrop As Boolean, _
Optional blnHidden As Boolean, _
Optional strSortKey As String) As Boolean
Dim vsoCell As Visio.Cell
Dim intRowIndex As Integer
Dim strValue As String
On Error GoTo AddCustomProperty_Err
Dim blnReturn As Boolean
blnReturn = False
Dim strCell As String
strCell = "prop." & strLocalRowName
Dim exists As Boolean
exists = visShape.CellExists(strCell, visExistsAnywhere)
If exists = True Then
blnReturn = True
GoTo HandleReturn
End If
If visShape.SectionExists(visSectionProp, False) = False Then
visShape.AddSection (visSectionProp)
End If
' Add a named Custom Property row. In addition to
' adding a row with the local name (strLocalRowNname),
' this call will usually set the universal name of
' the new row to strLocalRowName as well.
' However, the universal row name will not be set
' if this shape already has a custom property row
' with the universal name (NameU) equal to strLocalRowName.
intRowIndex = visShape.AddNamedRow(visSectionProp, _
strLocalRowName, VisRowIndices.visRowProp)
' The columns of the properties that this functions
' sets are fixed, and can be accessed directly using
' the CellsSRC method and column index.
' Column 1: Prompt
' Get the Cell object.
Set vsoCell = visShape.CellsSRC(visSectionProp, _
visRowProp + intRowIndex, visCustPropsPrompt)
SetCellValueToString vsoCell, strPrompt
' Any cell in the row can be used to set the
' universal row name. Only set the name if
' strRowNameU differs from the local name and
' is not blank.
If (strLocalRowName <> strRowNameU And _
Len(strRowNameU) > 0) Then
vsoCell.RowNameU = strRowNameU
End If
' Column 2: Label
Set vsoCell = visShape.CellsSRC(visSectionProp, _
visRowProp + intRowIndex, visCustPropsLabel)
SetCellValueToString vsoCell, strLabelName
' Column 3: Format
Set vsoCell = visShape.CellsSRC(visSectionProp, _
visRowProp + intRowIndex, visCustPropsFormat)
SetCellValueToString vsoCell, strFormat
' Column 4: Sort Key
Set vsoCell = visShape.CellsSRC(visSectionProp, _
visRowProp + intRowIndex, visCustPropsSortKey)
SetCellValueToString vsoCell, strSortKey
' Column 5: Type
Set vsoCell = visShape.CellsSRC(visSectionProp, _
visRowProp + intRowIndex, visCustPropsType)
strValue = CStr(vsoPropType)
SetCellValueToString vsoCell, strValue
' Column 6: Hidden
Set vsoCell = visShape.CellsSRC(visSectionProp, _
visRowProp + intRowIndex, visCustPropsInvis)
strValue = CStr(blnHidden)
SetCellValueToString vsoCell, strValue
' Column 7: Ask to drop
Set vsoCell = visShape.CellsSRC(visSectionProp, _
visRowProp + intRowIndex, visCustPropsAsk)
strValue = CStr(blnAskOnDrop)
SetCellValueToString vsoCell, strValue
HandleReturn:
AddCustomProperty = blnReturn
Exit Function
AddCustomProperty_Err:
Debug.Print Err.Description
End Function
'
' from v2007 sdk
'
Public Sub SetCellValueToString(vsoCell As Visio.Cell, _
strNewValue As String)
On Error GoTo SetCellValueToString_Err
' Set the value for the cell.
vsoCell.FormulaU = StringToFormulaForString(strNewValue)
Exit Sub
SetCellValueToString_Err:
If Not (vsoCell Is Nothing) Then
If (vsoCell.Application.AlertResponse = 0) Then
' needs a little more information when if fails
MsgBox Err.Description & " " & vsoCell.Shape.Name & " " & vsoCell.Name
Else
Debug.Print Err.Description
End If
Else
Debug.Print Err.Description
End If
End Sub
'
' from v2007 sdk
'
Public Function StringToFormulaForString(strIn As String) As String
Dim strResult As String
On Error GoTo StringToFormulaForString_Err
strResult = strIn
' Replace all (") with ("").
strResult = Replace(strResult, Chr(34), _
Chr(34) & Chr(34))
' Add ("") around the whole string.
strResult = Chr(34) & strResult & Chr(34)
StringToFormulaForString = strResult
Exit Function
StringToFormulaForString_Err:
Debug.Print Err.Description
End Function
Wow ! . thank you!
For moving the value to the custom properties I suppose that I need to try the following things:
#1 - Run the macro or function through the Shapesheet "action" properties and then add in the code for the assignment of custom properties fields for the relevant values.
or....
#2 - Develop a function from the code that you have added and allocate the function in the relevant custom properties fields. the function would need to return the Name and NameU values.
Thanks a lot for your help !
JD
Experience has shown that many users that work with the DataWizard want to automate the refresh/save process of their documents. Usually this ends up as another macro that calls the add-in. The offered code would probably fit very nicely into that type of workflow.
have a great one,
al
Browser ID: smf
(is_webkit)
Templates: 1:
Printpage (default).
Sub templates: 4:
init,
print_above,
main,
print_below.
Language files: 1:
index+Modifications.english (default).
Style sheets: 0:
.
Hooks called: 56 (
showintegrate_autoload, cache_get_data, integrate_pre_load, integrate_load_session, integrate_verify_user, cache_get_data, integrate_user_info, integrate_load_board, cache_get_data, integrate_board_info, cache_get_data, integrate_allowed_to_general, integrate_pre_load_theme, cache_get_data, integrate_allowed_to_general, integrate_simple_actions, integrate_allowed_to_general, integrate_load_theme, integrate_pre_log_stats, cache_get_data, integrate_actions, integrate_pre_parsebbc, integrate_bbc_codes, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_menu_buttons, integrate_current_action, integrate_theme_context, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general)
Files included: 25 - 925KB. (
show/home/iw0lkfe3x6cq/public_html/vgforum/index.php, /home/iw0lkfe3x6cq/public_html/vgforum/Settings.php, /home/iw0lkfe3x6cq/public_html/vgforum/cache/db_last_error.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/QueryString.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Auth.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Errors.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Load.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Security.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Compat.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Db-mysql.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApi.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApiInterface.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/APIs/FileBased.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Charset.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/Metadata.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/QuickCheck.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Session.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Logging.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Class-BrowserDetect.php, (Current Theme)/languages/index.english.php, (Current Theme)/languages/Modifications.english.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Printpage.php, (Current Theme)/Printpage.template.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/CaseUpper.php)
Memory used: 799KB.
Tokens:
post-login.
Cache hits: 7: 0.00102s for 22,301 bytes (
showget modSettings: 0.00042s - 19982 bytes, get known_languages: 0.00015s - 1277 bytes, get board_parents-0: 0.00012s - 2 bytes, get permissions:-1: 0.00009s - 50 bytes, get theme_settings-1: 0.00013s - 980 bytes, get log_online-update: 0.00009s - 10 bytes, get menu_buttons--1-english: 0.00002s - 0 bytes)
Cache misses: 1: (
showget menu_buttons--1-english)
Queries used: 9.
[Show Queries]