Hi folks,
As a relative newbie, I have created a Ribbon-Add-In for Microsoft Visio with Visual Studio 2010 and I really like doing this so far, but I have one major problem that I can't get over.
I try to dynamically change the stencil by reacting to events like ShapeAdded. I managed to delete a master from the stencil by doing something like this:
vsoMaster.Delete()
However, if I want to add a new master to an empty stencil (after all masters have been deleted) I do this:
Dim vMaster = vsApplication.Documents.Item("test.vss").Masters.Add()
This produces an empty master in the stencil.
Now, if I want this master to have a shape, I always get COMExceptions, e.g. when I try to do stuff like this:
vMaster.Shapes.Item(1).CellsSRC(Visio.VisSectionIndices.visSectionObject, Visio.VisRowIndices.visRowLine, Visio.VisCellIndices.visLineColor).FormulaU = "THEMEGUARD(RGB(0,0,0))"
It seems plausible for the program to react like that because there is no shape yet that I could edit like that, but I can't find a way to assign a shape to the master.
Does anyone know a way to do that?
Thanks in advance for your help and best regards from Osnabrueck, Germany.
Lennard
before we get too far into this, did you check this out?
http://www.visguy.com/2008/02/25/edit-visio-masters-programmaticallythe-right-way/
and before you attempt to edit the internal shape of the master, ensure that one was returned..
al
Thanks for the quick reaction.
I tried the above but I struggled to define a master that I could copy and open (since the stencil is empty).
I think I figured out the heart of my problem though.
I can't manage to get new instances of any Visio entities, such as Master, Shape etc.
If I try to initialize a new Shape:
vsShape = New Visio.Shape()
I get a COMException, telling me that the class was not registered:
HRESULT: 0x80040154 REGDB_E_CLASSNOTREG
What class do I have to register? And how do I do that?
Please help me, I'm really stuck here. Thanks.
Afaik you can't create a new shape in Visio like that.
You can drop a shape from another stencil or you can draw a new shape, for example as rectangle and then modify it.
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: 50 (
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_put_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_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: 776KB.
Tokens:
post-login.
Cache hits: 8: 0.00161s for 22,302 bytes (
showget modSettings: 0.00045s - 19983 bytes, get known_languages: 0.00014s - 1277 bytes, get board_parents-0: 0.00010s - 2 bytes, get permissions:-1: 0.00007s - 50 bytes, get theme_settings-1: 0.00010s - 980 bytes, get log_online-update: 0.00001s - 0 bytes, put log_online-update: 0.00072s - 10 bytes, get menu_buttons--1-english: 0.00002s - 0 bytes)
Cache misses: 2: (
showget log_online-update, get menu_buttons--1-english)
Queries used: 10.
[Show Queries]