When I can not find it in Developing Visio Solutions (MS Press), this forum has become the place I most often turn to... thanks everyone for such a good resource.
Today's annoying programming issue is how to avoid having to develop my own parser to re-interpret the cell formulas. I need to extract the actual placement on the page of some shapes, I will be then using the X,Y point data to mathematically place other objects.
I know how to extract the cell formulas with fragments like
text = text & vbCrLf & " " & _
shpObj.CellsSRC(curGeomSect, curRow, curCell).LocalName & ": " & _
shpObj.CellsSRC(curGeomSect, curRow, curCell).Formula
But I don't see an obvious way to avoid this and just get the current actual value that the formula is producing in that cell. In other words, consider the Show Shapesheet command where you can toggle between the actual value and the underlying formula with a right-click button - I need something like that to give me the final value programmatically.
How do I extract the actual data value from the shape's cell?
DCK,
Here's a few:
shp.Cells("PinX").ResultIU (always inches)
shp.Cells("PinX").Result("mm")
shp.Cells("PinX").Result(Visio.VisUnitCodes.visMillimeters)
Quote from: Visio Guy on April 28, 2010, 12:06:17 AM
shp.Cells("PinX").ResultIU (always inches)
shp.Cells("PinX").Result("mm")
shp.Cells("PinX").Result(Visio.VisUnitCodes.visMillimeters)
Great, I had lost track of the ResultIU method. That works well.
I'm building up a routine to grab the points in my ploygons now. I had to step back and convert any arc types back to line types as a pre-step, but otherwise it seem direct.
Is there any easy way to translate it to the page coor system, or must I add the offset of the shape transform points myself to get the page values? Update, is the answer to this as simple as
xxx.Result(Visio.VisUnitCodes.visPageUnits)
Update #2, no that does not work, it simply used the inches I have set for the page, no translaton occurs.
In the ShapeSheet there are functions (Loc, LoctoPar,..) which translate coords in shapes to the coordinate system of the page and vice versa.
But I don't know if they have an equivalent in VBA. If not you could either add User.cells to your shapes and use the functions there (akward) or calculate them yourself based on PinX/Y, LocPinX/Y and the Rows of the ShapeTransform section, like you suggested yourself.
I use the last method myself, because I don't know about a VBA method that does the trick, but if one of the other members knows a better way, I would like to learn that, too.
shp.XYToPage will help. Usage is:
shp.XYToPage(x, y, xprime, yprime)
But if you are getting the Paths property, the coordinates are that of the parent object, so you might already have page-coordinates.
I just don't seem to understand this, something is missing, please say it again for me.
I see XYToPage method, and that is can be called for a shape on a page or master object, but I don't get what xprime and yprime are to be set to. It says: y-coordinate corresponding to y in the Page or Master object's coordinate system. But if I had that, I would not need such a function. Oh! Never mind, I am not thinking like a VB person, this is the RETURN value set and I presume I need to give it the dummy variable to fill out. Sorry, too much C on my mind.
So then the question becomes how do I use this with the individual (and variable number of) points of my geometry shape? I can not go from
X = shpObj.CellsSRC(curGeomSect, curRow, 0).Result(visio.VisUnitCodes.visPageUnits)
Y = shpObj.CellsSRC(curGeomSect, curRow, 1).Result(visio.VisUnitCodes.visPageUnits)
to be
shpObj. XYToPage(x, y, xprime, yprime)
And the method XYToPage is not exposed as part of the CellsSRC - its not clear to me how to call it on the geometry cells. The text refer to "a point" as if that is clear, but i just do not get how this works with a shape with multiple points.
bump
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: 62 (
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_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: 773KB.
Tokens:
post-login.
Cache hits: 7: 0.00089s for 22,301 bytes (
showget modSettings: 0.00033s - 19982 bytes, get known_languages: 0.00015s - 1277 bytes, get board_parents-0: 0.00011s - 2 bytes, get permissions:-1: 0.00008s - 50 bytes, get theme_settings-1: 0.00012s - 980 bytes, get log_online-update: 0.00009s - 10 bytes, get menu_buttons--1-english: 0.00001s - 0 bytes)
Cache misses: 1: (
showget menu_buttons--1-english)
Queries used: 9.
[Show Queries]