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

take value from excel files via autocad vba

  • Thread starter Thread starter Pombia
  • Start date Start date

Pombia

Guest
hello to everyone, reading a little forum on this theme I couldn't find a solution to this problem.

having this code:
dim reg as acadtext
dim textreg as string
dim ip(0 to 2) as double
dim x as double, y as double, z as double, rot as double

textreg = regionetext.text
x = 2.875
y = 10.4
z = 0
ip(0) = x: ip(1) = y: ip(2) = z

set reg = thisdrawing.modelspace.addtext(textreg, ip, 0.2)
reg.layer = 0
reg.color = acbylayer
reg.alignment = acalignmentcenter
reg.textalignmentpoint = ip
I would like the textreg = to be taken from a cell of an excel file outside the dgw and not from the text box I entered in the userform.

Can anyone help me?
 
dim excelsheet as object
dim filename as string

filename = "c:\tuofile.xls"
set excelsheet = getobject(filename)

excelsheet.application.visible = true
cell = excelsheet.application.cells(1, 1)

cell contiene il valore della cella a1

buon divertimento
 
Still troubles, having added the code does not spoil me the same.

other solutions?
 
dvb contains a function that reads a cell of excel described by filename, row and column.
vba verification, tools/references must refer to the version of excel in use.Cattura.webpIf you have problems, ask.
bye
 

Attachments

I solved using another code and activating the references. Thanks for the help, I have problems because they are at first arms :)
 
a seguito richiesta, posto un esempio di richiamo della funzione vlookup in excel

sub testvlookup()

dim prova as string
dim obxls as object
dim wkfile as workbook
dim shfile as worksheet

set obxls = getobject(, "excel.application")

obxls.application.visible = true

set wkfile = obxls.activeworkbook
set shfile = wkfile.activesheet
'set shfile = wkfile.worksheets(combobox1.text)

prova = wkfile.application.worksheetfunction.vlookup("c", shfile.range("f1:g8"), 2, false)
'prova = shfile.application.worksheetfunction.vlookup(listbox2.list(x), shfile.range(l9, l28), 3, false)msgbox test

end

p.s.: for child
blue parts contain your settings, swap.
bye
 
Bye to all,
I am new in the field and I would need to realize a vbs and vba.
autocad allows to export the attributes of the selected blocks in excel format.
what I want to do is to create the reverse process; or import an external table in excel in autocad, to update the blocks I want.
Is that possible?
Thank you.
 
in the express section blocks, find the command <import attribute="" information=""> That's what it takes.</import>
 
in the express section blocks, find the command <import attribute="" information=""> That's what it takes.</import>
You mean express tools of autocad, don't you? Then I have to put it in the installation.
 
code is writing it shape. if you want to use this method and practice vba, create a software in excel that allows you to edit the txt file.
 
code is writing it shape. if you want to use this method and practice vba, create a software in excel that allows you to edit the txt file.
I solved it in a simpler way.
I imported from excel the .txt file and sucessivamnete re amounts the .txt file modified in autocad.

Thank you
you were helpful
 

Forum statistics

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

Members online

No members online now.
ciao
Back
Top