Hi all,
i have almost completed my project, but i am facing a problem.
I have a VBA program ( in ACAD), that opens a workbook and retrieve the data to generate drawings , based on excel cells values; this works perfectly.
Now , i want my ACAD program to load this same WB in excel, then execute a macro (based in the excel WB), then when complete continue to run the program in ACAD.
Before the first Excel macro is executed, it needs to get a value from ACAD user form input box, then use it for its macro ( Excel).
So my the question is in the title : how i can run the macro in excel from ACAD ?
i cannot figure out the code associated to this. Hope it is clear.
This is the code i try to run the macro:
it opens the excel sheet, but then excel freeze as soon as it passes the line "run..."
Sub DrawCablesFromExcelFile(FileNameAndPath As String, SheetName As String)
Dim MyXL As Object
Dim ExcelFound As Boolean
' Check if Excel is running.
On Error Resume Next
Set MyXL = GetObject(, "Excel.Application")
If Err.Number <> 0 Then ExcelFound = True
Err.Clear ' Clear Err object in case error occurred.
ExcelFound = DetectExcel
' Set the object variable to reference the file you want to use.
Set MyXL = GetObject(FileNameAndPath)
' Show Microsoft Excel.
MyXL.Application.Visible = True
MyXL.Parent.Windows(1).Visible = True
' Draw in AutoCAD
Dim TrayWidth As Double, TrayHeight As Double, CableDia As Double
Dim NoRows As Double, NoCols As Double, i As Integer, r As Integer, Tray2Check As String, ODCheck As Object
'**********************
' Recherche du Node dans le cable schedule et mise n Forme pour le traitement CAD
'**********************
MyXL.Application.Run "Schedule4Trays.xlsm!ODCheck"
'***********************************
' Logique de tri dans Excel et dessin du cable
'************************************
r = 2
With MyXL.Sheets("Sheet1")
.Activate
Thanks for your help.
Bookmarks