Microsoft Visio | How to perform VSTO (or alternative) from a Server - vsto

Objective:
I have a Web Application.
I have some Microsoft Visio files present in my Application.
I want to process (edit/export/print) these Visio files (Note: Opensource tools like LibreOffice Draw are not giving the same quality like Visio)
Current Progress: I got to know about Microsoft VSTO and achieved some basic operation by using VSTO
Sample code of VSTO
string docPath = "input.vsdx";
this.Application.Documents.Open(docPath);
int pageIndex = 1;
Visio.Pages visioDocPages = this.Application.ActiveDocument.Pages;
if (pageIndex <= visioDocPages.Count) {
// Use `visioDocPages[pageIndex]` for some processing
}
this.Application.ActiveDocument.Close();
Queries:
VSTO seems to be an Automation library, so I fear it will fail when multiple files needs to be processed from a Server
Are there any other methods to work on visio (like edit, export, print, etc) from a Server environment
Am looking for either officail Microsoft packages OR Open Source ones (NOT looking for paid packages like https://products.aspose.com/diagram/net/)

VSTO is a layer on top of the COM addin API useful only for developing Office addins. It cannot be used from external applications.
No Office applications (Visio included) can be used from a service (such as IIS). Look at the Open XML API (https://learn.microsoft.com/en-us/office/client-developer/visio/how-to-manipulate-the-visio-file-format-programmatically) - it will let you manipulate vsdx files without Visio.

Related

How do you detect why Document.Open freezes when opening an RTF?

Context:
VBA macro embedded in an MS-Word document.
Old code running for 15+ years under Word 2003 without issue.
Upgraded to Word 2019
Existing/Previous RTFs open without issue
Upgraded server from "Windows Server 2008 R2 Standard" to "Windows Server 2016 Datacenter"
The troublesome RTF is a copy of another RTF that works without issue. No edits were made.
I make the call
On Error GoTo docerr
Set gobjDoc = Documents.Open(gstrTEMPLATE_PATH + gstrTEMPLATE_NAME)
docerr:
WriteLog ("ERROR Documents.Open: " & Str(err.Number) & "-" & err.Description)
where gstrTEMPLATE_PATH + gstrTEMPLATE_NAME provides a fully qualified path. I've logged this value it continues to be accurate.
For the new/copied RTF, the interpreter gets to the Documents.Open statement and never returns. No error is thrown.
Does anyone know why is doesn't return? Is there a way to force a return?
I added the parameter OpenAndRepair:=True with no effect.
FYI: This is my first question on this forum.
The Considerations for server-side Automation of Office article states the following:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
Microsoft strongly recommends that developers find alternatives to Automation of Office if they need to develop server-side solutions. Because of the limitations to Office's design, changes to Office configuration are not enough to resolve all issues. Microsoft strongly recommends a number of alternatives that do not require Office to be installed server-side, and that can perform most common tasks more efficiently and more quickly than Automation. Before you involve Office as a server-side component in your project, consider alternatives.
For example, the Open XML file formats are a public standard. See Welcome to the Open XML SDK 2.5 for Office for more information.
Also you may conside using any third-party components designed for the server-side execution, especially, for RTF files.

Automate MS project

Is there a way that we can automate the input in ms project 2010. Below are the scenarios:
We have a vb.net application that uses to inputs task name, hours, estimate and completion date time.
Is there a way that we can upload those date in ms project 2010.
There is a way. If you use desktop version of MS Project (Pro or Standard) then the only option you have is to use OLE automation.
Through the OLE Automation you will get a reference to an instance of Application class which is key class in every MS Office application. From the Application you can get a list of currently open projects using Application.Projects collection or even get current project using Application.ActiveProject.
As soon as you have a reference to a project you can access all tasks in the project using Project.Tasks collection. (Index of all collections starts with 1)
The most of Task fields like Name or Start date are available through properties of a Task: Task.Name = "something" or Task.StartDate = "1/1/2001"
Anyway here is a link: msdn.microsoft.com
Another story is if you have Project Server and you want to do all the things faster. In this case you should use PSI (Project Server Interface) - collection of web services which give you access to the most of Project Server functions.
MSDN has great articles with samples how to work with projects using PSI and here is a link: MSDN about PSI. You can search around the link to find more articles about other services available through PSI.
If you're able to put your data into Excel as mentioned in your comment, then it would be fairly straightforward to write a VBA program that reads the excel data and updates the Project tasks with the data in the workbook.

Saving multiple visio diagrams to HTML

I am maintaining a set of process diagrams in visio 2007. For viewing I save the files as HTML and publish them on a web server.
It works great but its a real pain to maintain (a paintain ;-).
I am looking for a way to do this as some kind of batch job, currently the process is:
open each file
file>save as web page
in the save as web page dialogue:
select location
publish > open new dialogue
change title (i dont mind if i have to miss that step)
select web page to insert it into (my template)
done
The tools I have availiable are:
Visual studio 2010 express (i prefer c# but whatever)
Visio 2007(i have another laptop with visio 2010 which i can use too but the source files will be 2007 - that's not changing for the moment)
Ruby - may be easier if it doesn't require office integration.
(BTW I know about process repository in OSS 2010 and i have tested it with visio 2010 web diagrams - that works and would probably be a better option for anyone who has the choice, though its not perfect)
(batch file or command line would also be cool but i have not found a way of saving as web page from command line)
You can use Visio's COM interop API to do what you want (I think). I'd start by just recording a macro while manually doing the export, and then look at the VBA code that generates. You could then adapt that in C#, or VBScript/VB6 if you want something you can call with a command shell.
As Jon highlights, there's a whole API for using the SaveAsWeb functionality from code. I wrote a post about it a little while ago, which you can see here:
http://visualsignals.typepad.co.uk/vislog/2010/03/automating-visios-save-as-web-output.html
The post is VBA based but the .net version is very similar and there's also examples in the Visio 2010 SDK:
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=12365

SharePoint like functionality for Office Documents

We have a document library that is built inhouse. We are migrating to SharePoint 2010 Document Library, but this will be a time consuming process and many very old documents may not get moved to SharePoint at all. I would like to provide the same experience for our users when they open a document from SharePoint or our legacy system. The behavior I would like is like when you open a Workbook or Document that is rendered in the browser using the "Open In Excel" and "Open in Word" button that you get when you open a document stored in a Share Point Document Library.
I am not sure what this technology is called or where to start looking to configure this or integrate into an addin.
Any starting points are much appreciated.
I'm not exactly clear on what your question is, but perhaps you are looking to use the Office Web Apps. This allows you to use the Office applications within the browser.

Office 2007/2003 VSTO Shared Add-In Design Query

I am designing a shared add-in using VB.Net 2008 and VSTO that has to fire up when any MS Office App is started. It has to work for both 2002, 2003 and 2007 applications. I have managed to put together a working add-in that pops up a test message stating the version of Office and the Application name and tested this across all the apps ok.
The next part of the solution is to code the application specific code that needs to run for document auditing and corporate protective marking as well as, for example; in Excel checking that all the Add-Ins are linked to the Network Add-Ins folder.
My approach from now was going to be to late bind against the application object and set one of my typed (e.g. Excel) application object references which exist in the code to this object.
I'm still relativly new to VSTO so if I am doing something odd please can you let me know! :)
Ta.
I have completed this project and did it the way I specified using late bindig. It works lieka dream for all office apps both XP and 2007. :) I feel like I am announcing this to myself though as I didn't recieve a single answer or comment. Maybe you should have sexed up the title a bit Mas. Yeah maybe I should.