Solved

Running Visio Macro from VBS File

Posted on 2016-10-28
3
34 Views
Last Modified: 2016-11-01
Hi,

I have the following inside a VBS/VB Script. This code runs in regular environment but when inside a VBS file, it is not running

Option Explicit
MacroExample

Sub MacroExample()

    Set AppVisio = CreateObject("visio.application")
    Dim vsoDoc As Visio.Document

    Set vsoDoc = AppVisio.Documents.Open("\\edcfs2\share2\nathsh\XenApp\Desktop\Drawing1.vsd")

    vsoDoc.ExecuteLine ("PageSel")
    Set vsoDoc = Nothing

End Sub

Open in new window


At the moment I am triggering it with a batch file - this code is tested to run 'hi world' function

 cscript \\edcfs2\share2\nathsh\XenApp\Desktop\Test\Temp\filename.vbs

Open in new window


Any help on resolving/pointing in the right direction is appreciated!
0
Comment
Question by:Shanan212
3 Comments
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 41865329
vbscript and VBA are not the same they are related but not the same
1
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41865419
Hi,

pls try
Option Explicit
MacroExample

Sub MacroExample()

    Set AppVisio = CreateObject("visio.application")
    Dim vsoDoc

    Set vsoDoc = AppVisio.Documents.Open("\\edcfs2\share2\nathsh\XenApp\Desktop\Drawing1.vsd")

    vsoDoc.ExecuteLine ("PageSel")
    Set vsoDoc = Nothing

End Sub

Open in new window

Regards
0
 
LVL 13

Author Closing Comment

by:Shanan212
ID: 41869253
Thanks!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now