.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Accessing existing VBA macros through .NET
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
76 Views, 1 Replies
08-15-2005 09:22 AM
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) 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.
Anonymous(anon)
N/A
Posts: 0
Re: Accessing existing VBA macros through .NET
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-23-2005 01:46 PM in reply to:
SuperFly
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...
