Re: Programmatically insert Visio pictures

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




Did some further work on this. The second parameter on sendkeys needs to be
False not True. This parameter tells the function whether to wait until
processing is complete before moving on to the next statement. It is the
"wait" parameter. We do NOT want to wait, as immediately after we send the
keys we call the insert function which pops up the file dialog box and gets
populated with the keys we sent. If wait is True, it takes the keys and
shoves them into the shape object, then moves on and inserts the picture.
This works perfectly in VBA in a Visio macro.

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.

"David Parker" wrote:

Not pretty, but a loop with something like the following would work:

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:200712615184m_elyam@xxxxxxxxxxxx
I also need to programmatically insert pictures into my Visio (2007) org
chart shapes (created with the wizard). Any idea how to do this? I cannot
seem to find any information on how and where these are kept or how they
can be accessed via the Visio object model. The reply above did not help
me achieve this. Maybe I am missing something?

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com


.



Relevant Pages

  • Re: Programmatically insert Visio pictures
    ... I don't like using sendkeys, but it is a quick way to use some existing addons. ... This works perfectly in VBA in a Visio macro. ... I may go back to my previous method of just reproducing the insert picture ...
    (microsoft.public.visio.developer)
  • Re: Programmatically insert Visio pictures
    ... Just an observation on David's SendKeys suggestion is that I would have ... also need to look at the image shape itself and then add the appropriate ... shoves them into the shape object, then moves on and inserts the picture. ... Dim shp As Visio.Shape ...
    (microsoft.public.visio.developer)
  • Re: Programmatically insert Visio pictures
    ... Re the cells I would just copy and the formulae from an existing image shape ... By using the no wait option on the sendkeys you get it to ... without waiting for the keys to be processed. ... This works perfectly in VBA in a Visio macro. ...
    (microsoft.public.visio.developer)
  • Re: Programmatically insert Visio pictures
    ... insert picture addon first, your program execution stops until the addon ... By using the no wait option on the sendkeys you get it to run ... without waiting for the keys to be processed. ... 'Invoke the insert picture dialog ...
    (microsoft.public.visio.developer)
  • RE: Open non MS applications
    ... SendKeys sends keystrokes to another program. ... Before I run it, I select a picture. ... goes to the Paint program (which doesn't have ... copy the new picture from Paint to the clipboard ...
    (microsoft.public.excel.programming)