CreateObject error after updating from Visio 2010 to 2016 RRS feed

  • Question

  • Hello Scripting Guys,

    I recently updated from Visio 2010 to Visio 2016 (32bit) and am now having a problem with a VBS script that I've been using to convert VSD files to PDF.

    Option Explicit
    Sub Main() 
    	If WScript.Arguments.Count <= 0 Then 
    		Wscript.Echo "Usage: vsd2pdf <inputfile> <outputfile>"		
    		Dim inputFilename : inputFilename = WScript.Arguments.Item(0)
    		Dim outputFilename : outputFilename = WScript.Arguments.Item(1)
    		VSD2PDF inputFilename, outputFilename
    	End If
    End Sub
    Sub VSD2PDF(strSourceFile, strDestFile)
      Const xlTypePDF = 1
      Const visOpenCopy = 1
      Const visOpenRO = 2
      Const visOpenMinimized = 16
      Const visOpenHidden = 64
      Const visOpenMacrosDisabled = 128
      Const visOpenNoWorkspace = 256
      ' Convert the VSD file into a PDF
    	Wscript.Echo "Processing : " & strSourceFile
      'Dim objVisio : Set objVisio = CreateObject("Visio.Application")
      Dim objVisio : Set objVisio = CreateObject("visio.InvisibleApp")
      ' Note: use visOpenRO + visOpenCopy in order to handle the case when the original VSD file is still open within VISIO.
      ' Without the visOpenCopy option, the script will fail if the original VSD file is already open.
      Dim objeDoc : Set objeDoc = objVisio.Documents.OpenEx(strSourceFile, visOpenRO + visOpenCopy + visOpenMinimized + visOpenHidden + visOpenMacrosDisabled + visOpenNoWorkspace)    
      objeDoc.ExportAsFixedFormat xlTypePDF, strDestFile, 1, 0
    End Sub

    When I run the following simple example, it's now returning an error related to CreateObject('Visio.Application'):

    C:\build>cscript vsd2pdf.vbs c:\temp\PL9_SUB_003.vsd c:\temp\PL9_SUB_003.pdf

    Microsoft (R) Windows Script Host Version 5.8

    Copyright (C) Microsoft Corporation. All rights reserved.

    Processing : c:\temp\PL9_SUB_003.vsd

    C:\build\vsd2pdf.vbs(30, 18) Microsoft VBScript runtime error: ActiveX component can't create object: 'Visio.Application'

    I'm going nuts trying to understand why this might be happening after the update.

    Can anyone offer some advice on how to troubleshoot the problem ?

    • Moved by Bill_Stewart Monday, December 18, 2017 1:37 PM Move to more appropriate forum
    Tuesday, December 12, 2017 3:40 AM

All replies

  • You have to run it in a 32 bit session.


    Tuesday, December 12, 2017 4:23 AM
  • False alarm - The problem wasn't introduced by Visio 2016 at all.  I did a fresh install on a different computer and the scripts ran fine.

    Then I went back to the computer that was experiencing the problem and went through the exercise of uninstalling and reinstalling Visio 2016 - which resulted in the scripts working just like it used to.

    It seems that the problem was likely induced by uninstalling Visio 2010 after installing Visio 2016.

    Sorry for blaming Visio 2016.

    Tuesday, December 12, 2017 7:39 AM