File Save Sequance Excel 2007

mc16v

New Member
Joined
Aug 25, 2011
Messages
2
Hi everyone

I have recently upgrading from Excel 2000 to 2007 and a File Save As macro nolonger works and I dont understand why, can you help! The macro should search the save folder and the save the current file as the next number in the sequance eg "Week 01" then "Week 02" etc

The problem line I have highlighted in red

Thanks very much in advance
mc16v



Sub SaveAs()

Dim strDirectory As String
Dim strBaseName As String
Dim strLastNumber As String
Dim intLastNumber As Integer
Dim strLastFile As String
Dim strNewFile As String

Application.CutCopyMode = False
ActiveWorkbook.Save

'set the base directory and name for your files
strDirectory = "C:\Users\User\Documents\#####\#####\"
strBaseName = "Week" & " "

With Application.FileSearch
.LookIn = strDirectory
.FileType = msoFileTypeExcelWorkbooks
.Filename = strBaseName & "*.xls"
If .Execute = 0 Then
strLastFile = strDirectory & strBaseName & "01.xls"
Else
strLastFile = .FoundFiles(.FoundFiles.Count)
End If
End With

strLastNumber = Mid(strLastFile, Len(strLastFile) - 6, 3)
intLastNumber = CInt(strLastNumber)
strNewFile = strDirectory & strBaseName & Format(intLastNumber + 1, "00") & ".xls"


ActiveWorkbook.SaveAs (strNewFile)


End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Firstly, Thanks for the quick reply,

reading that post it seems to be a "look for" macro? I have limited abilities with macros and I cant work out how to fit it in to perform the "Save As" command I am looking for.

Really appriciate your help.
:)
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top