Hello all
If possible, help from the Excel vlisp experts
I have an excel file that contains several worksheets
I want to separate each worksheet into a separate external excel file
I have a code that works fine as in the video
I would like to write it on vlisp
Thank you
(defun c:excel_Copy( / excel)
(setq excel (vlax-create-object "Excel.Application"))
(setq workbooks (vlax-get excel 'workbooks))
(setq fname (getfiled "Select Excel File:" (getvar "dwgprefix") "XLSX;XLS" 4))
(vlax-invoke-method workbooks 'Open fname)
(setq activeWorkbook (vlax-get Excel 'ActiveWorkbook))
(setq sheets (vlax-get activeWorkbook 'WorkSheets))
(setq i 0)
(vlax-for sh sheets(setq i (1+ i) sheet_names (cons (cons (vlax-get sh 'Name) i) sheet_names)))
(setq sheet1_index (cdr (assoc "1" sheet_names)))
(setq sheet1 (vlax-get-property sheets 'Item sheet1_index))
(vlax-invoke-method sheet1 'Copy (vlax-invoke-method activeWorkbook 'SaveAs "C:\\Users\\alaahossine\\Desktop\\000\\t000test" FileFormat:=xlOpenXMLWorkbookMacroEnabled))
)
Sub SaveAsPDFall()
Dim ws As Worksheet
Dim xPath As String
Dim SH As Worksheet
xPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each ws In ThisWorkbook.Worksheets
With ws
.Copy
Application.ActiveWorkbook.SaveAs Filename:=xPath & "\" & .Name & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
Application.ActiveWorkbook.Close False
End With
Next ws
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
![wwq.gif wwq.gif](https://forums.autodesk.com/t5/image/serverpage/image-id/976560i3761ECF297FA2103/image-size/large?v=v2&px=999)