int visCmdFilePrint = 1010;
try {
return Dispatch.call(oActiveX, "DoCmd", visCmdFilePrint).toInt();
boolean tVisible = true;
ActiveXComponent visio = new ActiveXComponent("Visio.Application");
visio.setProperty("Visible", new Variant(tVisible));
Object documents = Dispatch.get(visio, "Documents").toDispatch();
Object addon = Dispatch.get(visio, "Addons").toDispatch();
Object orgWizAddon = Dispatch.call((Dispatch)addon, "ItemU", new Variant("OrgCWiz")).toDispatch();
Object activeDoc;
int pge = 1; //Specifies the document page to be displayed before saving document
/*Move the current document to the first page before saving. This is done to ensure that this page is
* always the first one displayed when the document is opened.*/
activeDoc = Dispatch.get(visio, "ActiveDocument").toDispatch();
Object activeDocPage = Dispatch.get((Dispatch)activeDoc, "Pages").toDispatch();
//Get the first page as a page object
Object gotoPage = Dispatch.invokev((Dispatch)activeDocPage, "Item", pge, new Variant [] {new Variant(pge)}, new int[1]).toDispatch();
//Display the page name - just for debug purposes really
Variant activePageName = Dispatch.get((Dispatch)gotoPage, "Name");
System.out.println("Active page name is " + activePageName);
//Get the active window (I don't know why, but this is how its done with VBA
Object wnDow = Dispatch.get(visio, "ActiveWindow").toDispatch();
//Move to the first page
Dispatch.put((Dispatch)wnDow, "Page", gotoPage);