Sunday 29 January 2017

Export workbook .XLSM format to .XLS format.

Sub ExportWorkbook()
    Dim wb As Workbook
    Dim strPunitName As String
    Dim wbName As String

   Application.DisplayAlerts = False
    On Error GoTo Last
    Set wb = ThisWorkbook
    strPunitName = wb.Sheets(home).Range("C20").Value
    wbName = ThisWorkbook.Path & Application.PathSeparator & Trim(strPunitName) & ".xls" '&    Right(ThisWorkbook.Name, Len(ThisWorkbook.Name) - InStr(ThisWorkbook.Name, "."))
    If wbName <> vbNullString Then
    ThisWorkbook.SaveCopyAs FileName:=wbName
    End If
Application.DisplayAlerts = True
Last:
    If Err.Description <> vbNullString Then
    MsgBox Err.Description, vbInformation, title
    End
    End If
End Sub


No comments:

Post a Comment