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
- 2735 reads
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago