Solid Edge Framework Type Library
RunMacro Method
Solid Edge Framework Type Library > Application Object : RunMacro Method
Specifies the complete path and file name of the macro file that is to be run.
Description
Executes a specified macro.
Syntax
Visual Basic
Public Sub RunMacro( _
   ByVal Filename As String _
) 
Parameters
Filename
Specifies the complete path and file name of the macro file that is to be run.
Remarks
The macro name can be specified as either a file name or as the programmatic identifier of a Visual Basic OLE Automation server. Control returns to the caller as soon as the macro has been launched and activated. This implies that the macro has not necessarily completed running. In addition, launching a macro causes any running commands to be terminated.
Example
Imports System
Imports System.Runtime.InteropServices

Namespace Examples
    Friend Class Program
        <STAThread>
        Shared Sub Main(ByVal args() As String)
            Dim application As SolidEdgeFramework.Application = Nothing

            Try
                ' See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
                OleMessageFilter.Register()

                ' Attempt to connect to a running instance of Solid Edge.
                application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)

                application.RunMacro("Notepad.exe")
            Catch ex As System.Exception
                Console.WriteLine(ex)
            Finally
                OleMessageFilter.Unregister()
            End Try
        End Sub
    End Class
End Namespace
using System;
using System.Runtime.InteropServices;

namespace Examples
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application = null;

            try
            {
                // See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
                OleMessageFilter.Register();

                // Attempt to connect to a running instance of Solid Edge.
                application = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");

                application.RunMacro("Notepad.exe");
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                OleMessageFilter.Unregister();
            }
        }
    }
}
See Also

Application Object  | Application Members