Jump to content

save excel workbook to new location from autolisp

Mickey the Gr8

Recommended Posts

I need to know how to save a new excel workbook to a location of my choosing. I want to be able to open a new workbook, add data, and then save it in a folder in my project folder. I can do everything but save it to the new location. This is what I have so far.


(setq FilePath "T:\\reference material\\fuse_list_template.xls")
(setq ExcelApp (vlax-get-or-create-object "Excel.Application"))
(vla-put-visible ExcelApp :vlax-true)

(vlax-put-property ExcelApp "DisplayAlerts" :vlax-false)

(setq Wbk (vl-catch-all-apply 'vla-open (list (vlax-get-property ExcelApp "WorkBooks") FilePath)))


From here I am adding data from autocad electrical 2011 which works fine.

My problem is I want to save this to a location that is not the same as the original filepath.

I cannot find the code to do a "save as" to the excel workbook.

Any help would be appreciated. It should not be this complicated.







Link to comment
Share on other sites

Thanks. I think I overcomplicated it. My coworker also gave me a fix.


 (vlax-invoke-method mywb "saveas" fuse_list_loc msxl-xlnormal "" "" :vlax-False :vlax-False nil)
 (vlax-invoke-method xl 'QUIT)
 (vlax-release-object xl)


My lisp will now grab all of the fuse attributes from our panel layout in ACADE and organize it into a spreadsheet and save it in the project folder automatically. this gives us a Fuse list we can print out and stick in our panels with no effort, anymore. If you are interested in seeing what I did, I can send you a copy of the .lsp


I love Autolisp


thanks for the help



Link to comment
Share on other sites

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.

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...