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
- 2715 reads
Recent comments
5 years 34 weeks ago
6 years 20 weeks ago
6 years 32 weeks ago
6 years 34 weeks ago
6 years 36 weeks ago
6 years 41 weeks ago
6 years 49 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago