# choose xls or xlsm?

#### Trevor3007

##### Active Member
good evening,

I currently use the following vb:-

Sub savetab()
'
' savetab Macro
'
ActiveWorkbook.SaveAs Filename:="C:\times" & Application.PathSeparator & ActiveWorkbook.Sheets(1).Name
'

However i can only send this to my recipients as an xls...but before send the final draft, i need to use the other VB/macros which are contained within the workbook. Is it possible to save but chose either xlsm or xls?

KR
Trevor 3007

End Sub

#### Fluff

##### MrExcel MVP, Moderator
Code:
Sub SaveChoose()
If MsgBox("Do you want to save as xls?", vbYesNo) = vbYes Then
ActiveWorkbook.SaveAs "C:\Users\DaveC\Desktop\test\Fluff" & Application.PathSeparator & ActiveWorkbook.Sheets(1).Name & ".xls", 56
Else
ActiveWorkbook.SaveAs "C:\Users\DaveC\Desktop\test\Fluff" & Application.PathSeparator & ActiveWorkbook.Sheets(1).Name & ".xlsm", 52
End If

End Sub

Last edited:

#### Rick Rothstein

##### MrExcel MVP
Code:
Sub SaveChoose()
If MsgBox("Do you want to save as xls?", vbYesNo) = vbYes Then
ActiveWorkbook.SaveAs "C:[B][COLOR="#FF0000"]\[/COLOR][/B]Users[B][COLOR="#FF0000"]\[/COLOR][/B]DaveC[B][COLOR="#FF0000"]\[/COLOR][/B]Desktop[B][COLOR="#FF0000"]\[/COLOR][/B]test[B][COLOR="#FF0000"]\[/COLOR][/B]Fluff" & Application.PathSeparator & ActiveWorkbook.Sheets(1).Name & ".xls", 56
Else
ActiveWorkbook.SaveAs "C:[B][COLOR="#FF0000"]\[/COLOR][/B]Users[B][COLOR="#FF0000"]\[/COLOR][/B]DaveC[B][COLOR="#FF0000"]\[/COLOR][/B]Desktop[B][COLOR="#FF0000"]\[/COLOR][/B]test[B][COLOR="#FF0000"]\[/COLOR][/B]Fluff" & Application.PathSeparator & ActiveWorkbook.Sheets(1).Name & ".xlsm", 52
End If
End Sub
Why did you use Application.PathSeparator when you hard-code the back slash (your path separator) in the earlier part of the text string? Maybe you would want to do it this way instead...
Code:
Sub SaveChoose()
If MsgBox("Do you want to save as xls?", vbYesNo) = vbYes Then
ActiveWorkbook.SaveAs Replace("C:\Users\DaveC\Desktop\test\Fluff\" & ActiveWorkbook.Sheets(1).Name & ".xls", "\", Application.PathSeparator), 56
Else
ActiveWorkbook.SaveAs Replace("C:\Users\DaveC\Desktop\test\Fluff\" & ActiveWorkbook.Sheets(1).Name & ".xlsm", "\", Application.PathSeparator), 52
End If
End Sub

#### Fluff

##### MrExcel MVP, Moderator
I simply copied the OP's code & changed the path to test.

#### Rick Rothstein

##### MrExcel MVP
I simply copied the OP's code & changed the path to test.
Okay, I see that, so maybe my comment should be directed through to the OP... if you hard-coded the path separator, then you apparently know what it is and, as such, do not need to use Application.PathSeparator, rather, you can simply hard-code the same path separator directly... on the other hand, if you are not sure of the user's path separator, then you should probably use coding similar to what I posted in Message #3 where I use a hard-coded back space throughout the text string and then replace it with the Application.PathSeparator afterwards.

#### Trevor3007

##### Active Member
Code:
Sub SaveChoose()
If MsgBox("Do you want to save as xls?", vbYesNo) = vbYes Then
ActiveWorkbook.SaveAs "C:\Users\DaveC\Desktop\test\Fluff" & Application.PathSeparator & ActiveWorkbook.Sheets(1).Name & ".xls", 56
Else
ActiveWorkbook.SaveAs "C:\Users\DaveC\Desktop\test\Fluff" & Application.PathSeparator & ActiveWorkbook.Sheets(1).Name & ".xlsm", 52
End If

End Sub

Many thanks & works a treat. Your help has been very much appreciated.

1,082,369
Messages
5,365,049
Members
400,819
Latest member
Gossow

### This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...