Elias Posted September 23, 2020 Posted September 23, 2020 Hi there, I need VBA code for Dialog box due to I create a program in autocad and I need to export the data as excel file Quote
PeterPan9720 Posted September 23, 2020 Posted September 23, 2020 Hi @Elias, it seems little bit generic as question. which data you would like to export? Entire dwg a portion ? a line ? a table ? what the dialog box shall show ? please explain. Thank you. Quote
Elias Posted September 23, 2020 Author Posted September 23, 2020 Hi @PeterPan9720 I created a program that can help me to export the coordinates but I faced a problem which is I can't save the data by using the dialog box ( save as ) I hope you got my point. Quote
BIGAL Posted September 24, 2020 Posted September 24, 2020 Using VBA and a form just returns the correct subroutine to run next. Very basic stuff. Just Google you have to code in the form or else call a subroutine. Quote
PeterPan9720 Posted September 24, 2020 Posted September 24, 2020 (edited) @Elias Ok now I understood. There are more possibility: 1) Open Text File with the following code, and store coords into textfile, immediately save, so when you select on screen or in any other way your text or your block you can store there. Due to I guess you have more than one text you have to insert a prefix like the text content or a simply progressive number like as (This code shall be written inside Autocad VBA). (see documentation on print # at https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/printstatement PATH="C:\..... " ' insert the path where do you want to store your text file TESTFILE ="NAME OF FILE TO CREATE" Open PATH & "\" & TESTFILE For Output As #1 ' Open file for output. Print #1, "Text1"; Text1.Insertionpoint(0);Text1.Insertionpoint(1); Text1.Insertionpoint(2) or Print #1, Text1.Textstring; Text1.Insertionpoint(0);Text1.Insertionpoint(1); Text1.Insertionpoint(2) 'Text1.Textstring it's the text content 2) Open an Excel File and put coordinates into the cells of an opened sheet. (This code shall be written inside Autocad VBA). dim excelapp as object dim wkbkobj as object set excelapp = getobject (, "excel.application") set wkbkobj = excelapp.workbooks.open (filename:="c:.....xls") wkbkobj.Range("A1)".value = Text1.Textstring wkbkobj.Range("B1)".value = Text1.Insertionpoint(0) 'X wkbkobj.Range("C1)".value = Text1.Insertionpoint(1) 'Y wkbkobj.Range("D1)".value = Text1.Insertionpoint(2) 'Z You will find a lot of documentation how to point to Excel Cell from Autocad VBA. I'm sure that @BIGAL will find the same code on LSP language instead VBA easy on Google, and he can help you on that side. Edited September 24, 2020 by PeterPan9720 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.