ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   File name being changed (https://www.excelbanter.com/excel-programming/441140-file-name-being-changed.html)

bbotz

File name being changed
 
In 2003 Excel VBA, this code saved the name correctly:

Application.Calculation = xlCalculationAutomatic
ChDir "K:"

wNFileName = "k:Safety\" & Left(wFileName, Len(wFileName) - 4) & " " &
Format(Now(), "mmddyy") & ".xls"
ActiveWorkbook.SaveAs FileName:=wNFileName
ActiveWorkbook.Close
ChDir ".."
ActiveWorkbook.SaveAs FileName:="k:" & wFileName

So a file name of "Quota File MW 201003.xls" would save with exactly that
filename.

Just upgraded to 2007 and same code now saves

"Quota%20File%20MW%20201003.xls" which I assume is URL encoding. How can I
turn that off, or have Excel 2007 revert back to 2003 behavior??

Thanks!!


Wouter HM

File name being changed
 
Hi Bbotz,

I would replace all spaces " " with an underscore "_".
So you would get "Quota_File_MW_201003.xls", using

ActiveWorkbook.SaveAs FileName:=Replace(wNFileName, " ", "_")

Besides I see something strange in this part: "k:Safety\"
TMHO it should be "k:\Safety\"

HTH,

Wouter

bbotz

File name being changed
 
Can anyone please help with this???

"bbotz" wrote:

In 2003 Excel VBA, this code saved the name correctly:

Application.Calculation = xlCalculationAutomatic
ChDir "K:"

wNFileName = "k:Safety\" & Left(wFileName, Len(wFileName) - 4) & " " &
Format(Now(), "mmddyy") & ".xls"
ActiveWorkbook.SaveAs FileName:=wNFileName
ActiveWorkbook.Close
ChDir ".."
ActiveWorkbook.SaveAs FileName:="k:" & wFileName

So a file name of "Quota File MW 201003.xls" would save with exactly that
filename.

Just upgraded to 2007 and same code now saves

"Quota%20File%20MW%20201003.xls" which I assume is URL encoding. How can I
turn that off, or have Excel 2007 revert back to 2003 behavior??

Thanks!!



All times are GMT +1. The time now is 03:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com