Solved

Move Visio Orgcharts to Powerpoint using VBS

Posted on 2014-01-16
4
1,259 Views
Last Modified: 2014-01-24
Hi Experts,

I have the task to implement a function in a web application that creates orgcharts in Visio and Powerpoint (Intranet environment).
What I do so far:
In the Web application the user defines some filter critera and clicks on "Create Orgchart"
a vbs script is created that is downloaded by the user and executed on the user's desktop
this vbs-script creates an Excel file with the orgchart data on the user's desktop.
it than creates a Visio file and runs the orgchart-addon in order to build the orgchart.
So far, so good, evething works fine, the users have created many fine orgcharts and everybody is smiling.
Now they want to get these orgcharts into Powerpoint slides as much automated as possible.
I added the following after the orgchart is finished in my vbs-script:
I create a powerpoint object and load a template file
In Visio, I loop all pages
for each page I select all content (Orgchart) and copy it to the clipboard
Then I add a new slide in powerpoint and paste the orgchart into that slide
aftre doing some finetuning (resizing, positioning), the Powerpoint presentation contains as many slides as the visio file has pages and all orgcharts are copied over

And here comes the problem:
when I run the orgchart-wizard in my vbs-script, it starts that addon in visio.
But than the vbs-script moves to the next command even if the orgchart has not finished.
That leads to the following:
The orgchart-wizard not only creates the orgcharts on the specified pages in visio, but it also takes care of formatting them properly: shapes are rezised and positioned so that ithey look fine.
But the vbs-script continues with the Powepoint-part at once, before the formatting is ready so that the orgcharts that are copied over to Powerpoint are ugly :-(
Depending on the selected criteria, the orgchart-wizard takes some seconds or a minute,
If I try to wait some time using WScript.sleep 10000, the orgwiz halts and does not continue the formatting job...

Question: how can I tell the vbs-script to wait until the wizard has finished?
Or: what other method could I use to move the orgcharts over to Powerpoint?

Any idea?
Thanks a lot!

Kai
0
Comment
Question by:Lupo09
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
Scott Helmers earned 500 total points
ID: 39788449
It's been a while since I fiddled with VBS but I vaguely recall two ways to launch external code, one that waits for the launched program to finish and one that doesn't. See bWaitOnReturn in this article for an example of what I'm thinking.

Another choice would be have users run a Visio macro to launch the PPT creation code. I realize that requires them to take two actions instead of one, but by having them trigger execution of the second set of code themselves, you are assured that everything in Visio is exactly the way they want it. One way to make this easy for them is for your first set of code to place a button on the org chart; when they double-click the button, your second set of code could then remove the button (so it doesn't appear in PPT) and create the PPT deck.

BTW, if your use of copy/paste is getting the results you want in PPT, that's great. I've used a different approach -- creating and pasting an image -- as described in this article. It provides a high-fidelity rendering in PPT in cases where copy/paste of Visio shapes doesn't provide the best results.
0
 

Author Closing Comment

by:Lupo09
ID: 39792031
Hi Scott,

thanks for your reply.

I'm afraid the bWaitOnReturn parameter won't work as I don't start an executable, but a vasio addon:

Set VisApp = CreateObject("Visio.Application")
VisApp.visible = True
Set objAddOn = VisApp.Addons.ItemU("OrgCWiz")
objAddOn.Run ("/S-INIT")
objAddOn.Run ("/S-ARGSTR /FILENAME=H:\Data\... "  -  and a lot of parameters )

objAddOn.Run ("/S-RUN")

than I would have to apply the wshell.run method to the line

objAddOn.Run ("/S-RUN")

That doesn't work, or do you see a way to apply it to the visio-addon-object?

If I don't find a way to wait for the wizard, I would have to build up the PowerPoint file in a second routine that is triggered by the user after the visio wizard is done (like you proposed).

Your approach on how to create Powerpoint slides of Visio pages also is very interesting and valuable for me!

My approach was to select the shapes on a visio page and copy them to the clipboard and than paste them to the PowerPoint slide using pasteSpecial. Here I let the user either copy the orgchart over as an visio-object or as an image, depending on if he wants to edit the powerpont result or if he wants to hand it over to someone who should not be able to edit it. My code for that is:

pptPres.Slides(iSlideNo).Shapes.PasteSpecial 2
   where 2 = past as OLE Object and 10 =  paste as enhanced metafile

I think I can learn a lot of your Visio-Macros for creating those PowerPoint slides.

Thanks!

If you can think of a way to apply the waiting wshell.run-method to the orgchart-wizard-addon, I would very gladly hear of it.


Kai
0
 

Author Comment

by:Lupo09
ID: 39806442
Scott,

maybe you have an idea on howto use the Visio orgwiz-addon on an opened document.

Using the Standard procedure

    Set VisApp = CreateObject("Visio.Application")
    VisApp.visible = True
    Set objAddOn = VisApp.Addons.ItemU("OrgCWiz")
    objAddOn.Run ("/S-INIT")
    objAddOn.Run ("/S-ARGSTR /FILENAME= . . . and some more Parameters )
    objAddOn.Run ("/S-RUN")

will create a new document and run the wizard there.

Even if I open my document first with something like

   Set docsObj = VisApp.Documents
   Set DocObj = docsObj.Add("c:\myVisioFile.vsd")

the wizard will create a new document.

I would like to run the wizard on the current document so that I can open a document containing some macros (for transfering the pages to PowerPoint)  and then run the wizard there.

(running the wizard manually on an opened document using the GUI (orgchart-tab and "Import") will create the orgcharts within the opened document as I want. So it should be possible using vba / vbs as well, I guess)

Do you have an idea?

Thanks a lot!

Kai
0
 
LVL 30

Expert Comment

by:Scott Helmers
ID: 39807247
Interesting... I can't find a parameter or technique that will create the org chart in the same document as the code either; it always creates a new document. There may be a way, as you suggest, but I haven't stumbled across it.

Another approach: because the newly created org chart becomes the active document, run the create PPT code immediately after running the orgwiz code, i.e.,
Dim OrgChartDoc as Visio.Document
<<<create org chart>>>
Set OrgChartDoc = ActiveDocument
<<<run PPT code against OrgChartDoc>>>

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ability to add structure to Visio diagrams using containers, lists and callouts is one of my favorite features in Visio 2010. In this article we’ll examine containers. We’ll explore lists (http://www.experts-exchange.com/Microsoft/Applications/M…
Most folk recognise that Microsoft Excel, being a numbers-and-formulae-centric application attracts programmers due to the natural fit in mindset. Conversly, when opening Microsoft's dominant presentation creative application, few consider what…
This video teaches viewers how to create handouts from their slides and helps them decide how many slides to include per handout.
The viewer will learn how to edit text. This includes Font, Spacing, Resizing, Color, and other special text options.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question