LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 221
Default Problem saving file to My Documents

G'day Keith

Try this and see how you go, it is a modified version of a code I use to
Mail/SaveAs "less the (Mail) part of the code"

Sub SaveMy_ActiveWB()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim SourceWB As Workbook
Dim MyFilePath As String
Dim MyFileName As String

Set SourceWB = ActiveWorkbook

With SourceWB
If Val(Application.Version) < 12 Then
FileExtStr = ".xls": FileFormatNum = -4143
Else
Select Case SourceWB.FileFormat
Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
Case 52:
If .HasVBProject Then
FileExtStr = ".xlsm": FileFormatNum = 52
Else
FileExtStr = ".xlsx": FileFormatNum = 51
End If
Case 56: FileExtStr = ".xls": FileFormatNum = 56
Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
End Select
End If
End If
End With

MyFilePath = Environ$("C:\My Documents") & "\"
MyFileName = Sourcewb.Name & " " & Format(Now, "yyyymmdd h-mm")

With SourceWB
.SaveAs MyFilePath & MyFileName & FileExtStr,
FileFormat:=FileFormatNum
End With
End Sub

HTH
Mark


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I change default file for saving documents? Anna Excel Discussion (Misc queries) 1 November 5th 09 12:59 AM
Problem with saving documents as .csv file [email protected] Excel Programming 2 January 23rd 08 12:20 AM
Saving Excel File in Current Directory NOT My Documents Fredriksson via OfficeKB.com Excel Programming 1 November 6th 06 09:08 PM
Saving Excel File in Current Directory NOT My Documents Fredriksson via OfficeKB.com Excel Programming 0 November 6th 06 07:47 PM
cannot open documents as viruscan says problem file? Wagon Burner Excel Discussion (Misc queries) 0 February 27th 05 06:27 PM


All times are GMT +1. The time now is 04:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"