Jump to content

Recommended Posts

Posted

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 

Posted

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.

Posted

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.

 

 

 

2020-09-24_023143.thumb.jpg.a77919130bcc0ea2f00bea8b4b265508.jpg

Posted

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.

Posted (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 by PeterPan9720

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...