.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Accessing existing VBA macros through .NET

1 REPLY 1
Reply
Message 1 of 2
Anonymous
353 Views, 1 Reply

Accessing existing VBA macros through .NET

I'm trying to do a few things through a windows application using VB.Net:

1) open autocad and a specific drawing
2) run an existing VBA function w/ input parameters from .NET form
3) return outputs from VBA macro to .NET application

Is this possible? I'm a newbie to VB.NET but proficient in VBA. I've successfully opened the drawing I need using unmanaged code with my .NET form:

Imports System.Data.OleDb
Imports System.Math
Imports System.Runtime
Imports System.Runtime.InteropServices
Imports System.Runtime.InteropServices.Marshal
Imports System.Windows.Forms
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common

Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub MySub()
Connect2ACAD() 'procedure that checks for running autocad and opens new if not open.
Dim oApp As AcadApplication
Dim oDoc As AcadDocument
oApp = GetActiveObject("AutoCAD.Application.16")
oApp.Visible = True
oDoc = oApp.Documents.Open(filenam)
End Sub
End Class

The inputs and outputs of the function I have in VBA are all double datatype where the output is the area of a region created.
I know there's a RunMacro command, but this can't be used with input parameters or outputs. Any help whatsoever would be greatly appreciated - including better methods to start from scratch. Thanks,

J.P.
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

The only way I figured out how to get around it is the same way that I get LISP to talk with VBA or VB .net...Have the VB.net program write a txt file with the data needed for the VBA function...Then VBA reads in the file selecting what it needs...Then VBA writes out a file that tells VB.net what it needs...If you use "RunMacro" I think .net waits for it to finish...I could be wrong though...I know that if you run it from the command line via "SendCommand" .net waits...I know this is a conveluded way to do it, but I have no idea how else to make it work...Hope this helped...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost