XLA routines: EE_ExportSheetToXLS
EE_ExportSheetToXLS exports a worksheet to an XLS
Function EE_ExportSheetToXLS(strSheetName As String, strFilePath As String) As Boolean '- takes a sheet name '- takes a FullFilePath '- creates new wb '- delete existing file '- sheet.copy (new wb) '- saveas (FilePath) '- close '- returns True if success Dim wbkNew As Workbook Dim strNewFullFilePath As String 'http://excelexperts.com/xla-routines-eeExportSheetToXLS for updates on this function ThisWorkbook.Worksheets(strSheetName).Copy Set wbkNew = ActiveWorkbook strNewFullFilePath = Replace(strFilePath & "\" & strSheetName & ".xls", "\\", "\") On Error Resume Next Kill strNewFullFilePath On Error GoTo 0 On Error GoTo ErrH Application.DisplayAlerts = False wbkNew.SaveAs FileName:=strNewFullFilePath, FileFormat:=56 On Error GoTo 0 wbkNew.Close False Application.DisplayAlerts = True EE_ExportSheetToXLS = True Exit Function ErrH: If Not wbkNew Is Nothing Then wbkNew.Close False End If EE_ExportSheetToXLS = False End Function
»
- Nick's blog
- Login or register to post comments
- 2781 reads
Recent comments
5 years 41 weeks ago
6 years 27 weeks ago
6 years 39 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 48 weeks ago
7 years 4 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago