Does anyone have a way or know of code (macro or vba) that will read a
picture path from the custome properties for each shape and inset a picture
for each shape on the the org chart?
Or secondly, Does anyone know of a way to have the picture from the Access
database pulled into a visoio org chart form the data base?
EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Dim shp As Visio.Shape
Dim adn As Visio.Addon
Set adn = Visio.Addons("OrgC11")
'Loop thru your shapes
Set shp = Visio.ActivePage.Shapes("Assistant")
Visio.ActiveWindow.DeselectAll
Visio.ActiveWindow.Select shp, Visio.VisSelectArgs.visSelect
SendKeys "C:\Users\davidp\Pictures\anypicture.jpg{ENTER}", True
adn.Run "/cmd=InsertPicture"
'end loop
"Mark Mayle" wrote in message news:200712615...@yahoo.com...
Mark
Now for the problem. My program is a VB.net application with no user
interface (it will be kicked off via a separate application). It uses Visio
as an automation server; when I try to call the send method from my app I
get an error message stating: SendKeys cannot run inside this application
because the application is not handling Windows messages. Either change the
application to handle messages, or use the SendKeys.SendWait method.
I may go back to my previous method of just reproducing the insert picture
function manually. This works but I need to get all of the shape rows and
cells that describe the placement of the picture correct.
"Mark Mayle" <Mark...@discussions.microsoft.com> wrote in message
news:C3239765-BE5A-4D15...@microsoft.com...
Just an observation on David's SendKeys suggestion is that I would have
thought the following code should be in the reverse order
>> SendKeys "C:\Users\davidp\Pictures\anypicture.jpg{ENTER}", True
>> adn.Run "/cmd=InsertPicture"
ie:
'Invoke the insert picture dialog
adn.Run "/cmd=InsertPicture"
'add a DoEvents to ensure the dialog is active
DoEvents
'now add the file name
SendKeys "C:\Users\davidp\Pictures\anypicture.jpg{ENTER}", True
That may not solve your .Net porblem of course. In terms of adding your
owner image, it should be just a case of changing some User cells in the Org
chart shape plus some formulae in the image shape you're dropping:
User.ShowPicture = 1
User.HasPicture = 1
User.PictureAspectRatio = [need to calculate]
User.PictureID = [your image shape's Sheet.ID]
User.ExpandedForPicture = 1
Note, I haven't fully tested this but I these are the main ones. You'll
also need to look at the image shape itself and then add the appropriate
formulae once you've dropped the shape.
Best regards
John
John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
"Mark Mayle" <Mark...@discussions.microsoft.com> wrote in message
news:C3239765-BE5A-4D15...@microsoft.com...
>
It turns out that the order that David suggested works. If you call the
insert picture addon first, your program execution stops until the addon
completes; the dialog box asking for a file name comes up and waits for
input. Once you give it input then your sendkeys statement would run but
it's too late at that point. The problem is that the addon runs
synchronously. By using the no wait option on the sendkeys you get it to run
asynchronously, meaning that you send the keys in and then start the addon
without waiting for the keys to be processed. What makes this a little
questionable is there might be some system dependent timing issues between
how fast your keys are processed and when the dialog box comes up. If your
program thread maintains control and does not let the system process the
keys until it blocks (like when it waiting for user input in the dialog box),
this will work.
Thanks for the suggestions on the cell settings! I will give these a try.
What makes it somewhat more challenging is that some of the settings are
formulas that reference other shape settings. But I will trudge through
it.....
Mark
Yes, I've had a test now and see you're quite right. That's what I get for
questioning David's code. He must have used Visio before :)
Re the cells I would just copy and the formulae from an existing image shape
and amend their respective shape IDs. As you point out you'll need to
ensure that the shapes and cells exist in the drawing before referencing
them (ie drop the image shape onto the page to get its ID before trying to
write to the parent cells .
Best regards
John
John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
"Mark Mayle" <Mark...@discussions.microsoft.com> wrote in message
news:36BABBAF-F7BF-4ED9...@microsoft.com...