Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Interacting with Excel from Lisp - ExportAsFixedFormat

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
jshimkus
1382 Views, 4 Replies

Interacting with Excel from Lisp - ExportAsFixedFormat

I wasn't able to find out any information on what format the parameters are required to look like when passed along with the Method ExportAsFixedFormat.

 

I'm currently using the following code to change the active printer followed by the printout command

 

(vlax-put-property XL "ActivePrinter" "DocuCom PDF Driver on Ne03:")
(vlax-invoke-method XLS "Printout")

 where XL is my spreadsheet and XLS is the active worksheet.  This works but the printer controls filename and location.

 

(vlax-invoke-method XLS "ExportAsFixedFormat"

 I've found the ExportAsFixedFormat but can not find any documentation that shows how to format the parameters within LISP to send to Excel.

 

The object browser for VBA in Excel shows the following:

 

Sub ExportAsFixedFormat(Type As XlFixedFormatType, [Filename], [Quality], [IncludeDocProperties], [IgnorePrintAreas], [From], [To], [OpenAfterPublish], [FixedFormatExtClassPtr]) Member of Excel.Chart

 

I recording a macro and got the following that shows some additional information.

 

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\test.pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True

 

Is there any documention showing what this looks like when using the vlax-invoke-method?

 

4 REPLIES 4
Message 2 of 5
Shneuph
in reply to: jshimkus

Try:

 

(vlax-invoke-method XLS 'ExportAsFixedFormat)

???

I've never worked with Excel methods.. but the method is in 'symbol format not "string" in VisualLisp

 

EDIT:

You've seen this right?

http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6816.htm

 

EDIT #2:

Apparently, I didn't read it closely enough.. it says, "A symbol or string naming the method to be called."  My mistake.. I'd only ever seen symbols used.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 3 of 5
dgorsman
in reply to: jshimkus

Enumerated constant values are typically assigned integer equivalents; the Excel VBA object model documentation should indicate what these values are (inspection of values at run-time is another option).

 

Optional arguments in methods called from (vlax-invoke-method...) must all be filled out with either a defintitive value or nil.  This can get a little rediculous in LISP - I've had function calls with signatures like (vlax-invoke-method app_obj 'MethodName new_value nil nil nil nil nil nil nil nil nil nil...).

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 4 of 5
jshimkus
in reply to: jshimkus

Found the answer after re-reading dgorsman post!!!

 

After looking at the object browser in Excel for ExportAsFixedFormat  ... again ...

The 'XlFixedFormatType' took me to a section showing the members of XlFixedFormatType

 

xlTypePDF is set to 0

xlTypeXPS is set to 1

 

;;; This line will create a test.pdf file located on the c-drive

(vlax-invoke-method XLS "ExportAsFixedFormat" 0 "c://test"))

;;; This line will create a test.xps file located on the c-drive

(vlax-invoke-method XLS "ExportAsFixedFormat" 1 "c://test"))

 

Not sure about the Optional Parameters needing values?!?!?  The ExportAsFixedFormat works with just one optional parameter (The filename) and the Printout had none even though the object browser shows 9.  I'm using Excel 2010 so I don't know if that matters.

Message 5 of 5
hosneyalaa
in reply to: jshimkus

@jshimkus  & @dgorsman 

 

Thank you, I was looking for the topic

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost