lllisp Excel selected range
lllisp Excel selected range
Wish List Forums Get Connected Articles Publications Products About AUGI
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post:
click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection
below.
2011-09-04, 03:22 PM #1
carmine.iannotta342739
Excel selected range Login to
Member Give a
Good afternoon, i'm new in visual lisp programming, so i bone
Join Date: 2011-09 hope someone can help me.
Posts: 5 Is it possible to get a list with the values of cells in a range
selected by the user? 0
2011-09-04, 03:33 PM #2
Lee Mac
Re: Excel selected range Login to
I could stop if I wanted to Give a
This should help you: bone
Join Date: 2009-03
Location: London, England http://web2.iadfw.net/terrycad/LISP/GetExcel.lsp
Posts: 304 0
2011-09-06, 06:36 AM #3
carmine.iannotta342739
Re: Excel selected range Login to
Member Give a
bone
https://forums.augi.com/showthread.php?132825-Excel-selected-range&s=d033238e96fda1d207cd6c8f5eb8610a&p=1150815#post1150815 1/6
2/4/24, 7:22 PM Excel selected range
Join Date: 2011-09 Thank you Lee Mac, but in this code i need to specify the
Posts: 5 cell. Is there a way to get the cell selected in excel?
0
2011-09-06, 01:50 PM #4
irneb
Re: Excel selected range Login to
Certifiable AUGI Addict Give a
You need to look at the Excel ActiveX reference: bone
Join Date: 2015-11 http://msdn.microsoft.com/en-us/libr...ice.12%29.aspx
Location: Jo'burg SA
Posts: 4,512 From there you should be able to browse to the relevant 0
propery/object. E.g. from the Application object you get
the ActiveCell property, which contains a Range object.
This in turn either has an Address string or a Cells object
(i.e. column number & row number) - whichever you need.
2011-11-16, 07:58 AM #5
carmine.iannotta342739
Re: Excel selected range Login to
Member Give a
This is what i did until now: bone
Join Date: 2011-09
Posts: 5 Code:
(defun c:proex()
0
(vl-load-com)
(setq documento (getfiled "esplora" "esempi
(setq excel (vlax-create-object "Excel.Appl
(setq fogliolavoro (vlax-get-property excel
(setq attfoglio (vlax-invoke-method fogliol
(vla-put-visible excel :vlax-true)
(getint )
(setq selezione (vlax-get-property excel 'S
(print selezione)
What's wrong?
I need to store the values in the range in a list, how can I
go on?
2011-11-16, 09:53 AM #6
irneb
Re: Excel selected range Login to
Certifiable AUGI Addict Give a
bone
Originally Posted by carmine.iannotta342739
https://forums.augi.com/showthread.php?132825-Excel-selected-range&s=d033238e96fda1d207cd6c8f5eb8610a&p=1150815#post1150815 2/6
2/4/24, 7:22 PM Excel selected range
2011-11-16, 10:50 AM #7
irneb
Re: Excel selected range Login to
Certifiable AUGI Addict Give a
As an example I've modified your code a bit (marked in bone
Join Date: 2015-11 red):
Location: Jo'burg SA Code:
Posts: 4,512
(defun c:proex (/ documento excel fogliolavor
0
(vl-load-com)
(setq documento (getfiled "esplora" "esempi
(setq excel (vlax-get-or-create-object "Exc
(setq fogliolavoro (vlax-get-property excel
(setq attfoglio (vlax-invoke-method fogliol
(vla-put-visible excel :vlax-true)
(getint)
(setq selezione (vlax-get-property excel 'S
(vlax-for row (vlax-get-property selezione
(setq row-list nil) ;Initialize the tempo
(vlax-for cell (vlax-get-property row 'Co
(setq row-list (cons (vlax-get cell 'Va
)
(setq values-list (cons (reverse row-list
)
(vlax-release-object excel) ;Release the re
(reverse values-list) ;Return the list of v
https://forums.augi.com/showthread.php?132825-Excel-selected-range&s=d033238e96fda1d207cd6c8f5eb8610a&p=1150815#post1150815 3/6
2/4/24, 7:22 PM Excel selected range
Else you could run out of RAM quite quickly, not to mention
You might also want to close Excel before releasing the obje
2011-11-16, 02:15 PM #8
carmine.iannotta342739
Re: Excel selected range Login to
Member Give a
This is exactly what I need, thank irneb! bone
Join Date: 2011-09
Posts: 5
0
2011-11-17, 05:56 AM #9
irneb
Re: Excel selected range Login to
Certifiable AUGI Addict Give a
bone
Join Date: 2015-11 Originally Posted by carmine.iannotta342739
Location: Jo'burg SA This is exactly what I need, thank irneb!
Posts: 4,512 0
You're welcome
There's many ways of doing this, I'm not too sure how it
would perform if you've got multiple ranges selected in
excel - i.e. If you hold down the Ctrl key and select 2 or
more areas. From my tests it seems to work fine for 2
separate portions on the same sheet, but ends up with nil
values if you've selected across sheets.
BTW, why did your code use 13 in the getfiled call? I'd
think 12 would be more "correct":
1 = Ask for new file name, if exists ask user if they
want to overwrite. (I don't agree with this one)
+
4 = Allow other extensions than the one specified.
+
8 = Search for the file in the support paths if not
specified as full path.
fixo
Re: Excel selected range Login to
AUGI Addict Give a
You might be want to look at to do it bone
by Excel way using Input function:
(from my oldies so sorry for bad code manner)
Code: 0
Join Date: 2005-05
;; local defun
(defun RefSelection (/ *error* addr c2 c2 Exc
Location: Pietari, Venäjä (vl-load-com)
(defun *error* (msg)
https://forums.augi.com/showthread.php?132825-Excel-selected-range&s=d033238e96fda1d207cd6c8f5eb8610a&p=1150815#post1150815 4/6
2/4/24, 7:22 PM Excel selected range
Posts: 1,269 (if
(vl-position
msg
'("console break"
"Function cancelled"
"quit / exit abort"
)
)
(princ "Error!")
(princ msg)
)
(vl-catch-all-apply
'vlax-invoke-method
(list Wbk "Close")
)
(vl-catch-all-apply
'vlax-invoke-method
(list ExcelApp "Quit")
)
(mapcar
(function (lambda (x)(vl-catch-all-apply(
(if ( t ( l bj t l
Page 1 of 2 1 2 Last
Similar Threads
Get Excel range names in lisp Replies: 4
By marian.italian356732 in forum AutoLISP Last Post: 2013-02-25, 09:49 PM
Posting Permissions
You may not post new threads BB code is On
You may not post replies Smilies are On
You may not post attachments [IMG] code is On
You may not edit your posts [VIDEO] code is On
HTML code is Off
Forum Rules
https://forums.augi.com/showthread.php?132825-Excel-selected-range&s=d033238e96fda1d207cd6c8f5eb8610a&p=1150815#post1150815 5/6
2/4/24, 7:22 PM Excel selected range
https://forums.augi.com/showthread.php?132825-Excel-selected-range&s=d033238e96fda1d207cd6c8f5eb8610a&p=1150815#post1150815 6/6