• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

export data to excel with a command button

  • Thread starter Thread starter Dave1978
  • Start date Start date

Dave1978

Guest
Good morning they are greedy,
and work on behalf of a company as a technical designer. It's the first time I've been in a forum and I hope to follow the right procedures... If it weren't for me to listen.

always at the company for which I work I have created all the blocks in both 2d and 3d with within them the attributes that identify the respective code in order to be able to extrapolate its separate ones by extracting data on a excel sheet. Starting from this premise I ask you politely if it was possible to create a quick selection button that allows with a single clik to extract in a excel sheet the distinct materials from autocad without having to remake all the process of data extraction (not that it is so long, but I wanted to automate it ) with the possibility of selecting objects in the model space.
I temporarily extract the data in excel using a dxe model, but as mentioned, I wanted to automate it by creating a button. I have also tried to create this by using vba but not being hardware in the matter therefore I do not know if I have taken the right path
autocad use 2013

a greeting hoping to be clear
 
Hello, David.
I don't know where the problem is.
if I have correctly understood the macro works but you want to launch it with a click on a button,.
If that were the vbarun command does for you, search in the help and do some experiments, you'll be in five minutes.
 
Hello and thank you for the answer.
In fact, I had modified the initial request with copies and paste and the sentence is not clear...sorry.
what I would like to achieve is a "fast" command that when the load tells me to select only the elements on the model space to be able to extrapolate the distinct materials.

about the macro I tried to record it, but when the "load " to make it go back to the first screen of the data extraction then it does not work. Since I'm not in the matter I'm definitely wrong with something. Do you have any macros that can help me? then I think creating a button with a vba command is not difficult or if you have a procedure better yet.
 
I believe that if you are looking for numerous examples of extracting data from autocad to excel, both on this forum and on others.
When you threw down four post lines that we see them together.
 
hi pertengineering,
in the time "free" from work I tried to look for what could do to my case between the various forums and in this, but I did not find what I look for. I also tried to create it in person with a vba manual, but my ignorance in this matter is such that I do not even know where to go. I found an autolisp function that extracts all the blocks also dynamic ones and finding a discussion on how to transform an autolisp function to a vba I tried to convert it but nothing even with this way. It is not the philosophy of the forum, but you would be able to give me a basis on which to start by posting commands in vba ? would help me a lot. If this were not possible, would you post me of the sites where you can download it?

Thank you in advance for your availability and patience
 
ciao dave.
Scarica questo : http://www.emicad.it/emicad/simbolicad/manuali/vbadev.zipIt's 2000, but there's more recent versions, so there's everything you need to start.
You leave, where you stand and help.
:smile:
If I don't answer right away, take patience.
try to do simple things, if you know vba for excel you benefited.
then, there's another post that always talks about ac and excel, also follow what the macro is already ready (I think).
 
ciao pertenigineering,
ti ringrazio per il link e mi sono adoperato su alcuni esempi per prendere dimestichezza con vba anche se parto proprio da zero infatti non conosco nemmeno vba per excel. diciamo che sia cad che excel li sò usare bene, ma non la parte che concerne vba.
anche se ignorante in materia, è notevole anche vedere la "parte di programmazione" di un programma
oltre ad alcuni esempi ho trovato la seguente routine ( penso si dica così ) per vba :

sub ch12_extract()
dim excel as excel.application
dim excelsheet as object
dim excelworkbook as object
dim rownum as integer
dim header as boolean
dim elem as acadentity
dim array1 as variant
dim count as integer
' launch excel.
set excel = new excel.application
' create a new workbook and find the active sheet.
set excelworkbook = excel.workbooks.add
set excelsheet = excel.activesheet
excelworkbook.saveas "attribute.xls"
rownum = 1
header = false
' iterate through model space finding
' all block references.
for each elem in thisdrawing.modelspace
with elem
' when a block reference has been found,
' check it for attributes
if strcomp(.entityname, "acdbblockreference", 1) _
= 0 then
if .hasattributes then
' get the attributes
array1 = .getattributes
' copy the tagstrings for the
' attributes into excel
for count = lbound(array1) to ubound(array1)
if header = false then
if strcomp(array1(count).entityname, _
"acdbattribute", 1) = 0 then
excelsheet.cells(rownum, _
count + 1).value = _
array1(count).tagstring
end if
end if
next count
rownum = rownum + 1
for count = lbound(array1) to ubound(array1)
excelsheet.cells(rownum, count + 1).value _
= array1(count).textstring
next count
header = true
end if
end if
end with
next elem
excel.application.quit
end sub

penso sia ciò che mi serve, ma mi dà errore e nel dettaglio : " errore di compilazione . tipo definito dall' utente non definito ".

in merito al posto che accennavi è il seguente ? : http://www.cad3d.it/forum1/showthread.php?25749-lanciare-macro-di-excel

ciao davide
 
Yes, this macro extracts attributes from blocks of an autocad design, brings the values of attributes to a excel sheet.

type defined by the undefined user indicates that the compiler does not know a type of object.

As in a matrioska, you can't access a statuette if you don't know who owns it.
excel.application who owns it?
It's an application so it connects to an executable, to a library.
is a "mamma" class (also called namespace) add it as reference (so, in the vba window for autocad (go in with alt f11) look for tools -> references and microsoft ideas excel 12.0

as a culture, so as to give vba the matrioska "excel"
opening matrioska, excel can open multiple files simultaneously (imagine several statuettes) so more 'excel.application.workbooks (see s=plurale excel handles multiple files)
the workbook (singular, a stauetta you want to examine) is a folder of excel, a classic .xls file to understand.
This also has children, sheets, which are called workbooks.sheets.(s=plurale,a workbook has more sheet)
even the sheets have children, among others the cells sheet.cells.
Cells have properties including cell value.valuetry to reason us, they are all embedded, if you want to get to the value of the cell, you have to pass for all other elements...:smile:

I apologize if I have returned some "rounding" to the concept, resume my way of seeing object programming.

about the post is as follows:http://www.cad3d.it/forum1/showthread.php?16737-macro-per-collegare-excel-e-autocadBut I suggest you don't put too much meat on the fire, continue with that post because you're close to it.
Bye.
 
Hi.
I popped up the voice microsoft excel object library because other references to excel I did not find in references in the vba editor.
You know I don't know how to change it... I tried to think about it... but nothing.
Now it also gives me vba error message when giving the command run " impossible to access " attribute.xls"

I also tried on the link that you kindly turned me but only to try to understand and/or travail a solution but I did not find what I was looking for


Hi.
 
Hi.
I popped up the voice microsoft excel object library because other references to excel I did not find in references in the vba editor.
You know I don't know how to change it... I tried to think about it... but nothing.
Now it also gives me vba error message when giving the command run " impossible to access " attribute.xls"

I also tried on the link that you kindly turned me but only to try to understand and/or travail a solution but I did not find what I was looking for


Hi.
I suggest you go to excel and the vba (always alt+f11) start moving the first steps.
take small examples and try to make them work.
slowly you will take confidence and solve your problem by moving on autocad.

Good vba!
Sergio
 
I suggest you go to excel and the vba (always alt+f11) start moving the first steps.
take small examples and try to make them work.
slowly you will take confidence and solve your problem by moving on autocad.

Good vba!
Sergio
Could I know where you came with your research? The subject is very important for a designer. Say hi. .
 
Could I know where you came with your research? The subject is very important for a designer. Say hi. .
Hello and welcome.
See you http://www.cad3d.it/forum1/showthread.php?16737-macro-per-collegare-excel-e-autocad/page5 use autocad 2013 ,I do not know well the support it has with vba since we jealously keep 2012 :wink: .
The vba is 32bit, so you have to assess whether to switch to .net that is 64bit.
I also use the .net, but always 2012, so there may be incompatibilities between the versions.
the maintenance of these incompatibilities (i.e., the probable rewriting of part of the code to adapt it to every change of version of autocad) + the fact that the program is different for every type of cartilage (it is practically impossible to have 2 companies with the same cartilage) is impossible for me without a significant time outburst, so I recommend you to join forces : the thing is not so difficult.
step and close.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top