Save as- FileName not working for some filenames

I have a code where in, I am trying to save the file with a required name.

Dim FilNameRq1 as string
Dim FormattingWbk as workbook
.
.
FormattingWbk.saveas FileNameRq1

FileNameRq1 here is \paer\Test Environment\Prep 01-25-18 12-00-59 PM\Classified Share Drive Report - Privates and Restricteds-en-None Members - WW0533969 - JOHN DIGGLE- 11-05-2017.xlsx

it works if the file name is \paer\Test Environment\Prep 01-25-18 12-00-59 PM\Test.xlsx

Upvotes: 0

Views: 699

Answers (2)

Khizhny Andrey
Khizhny Andrey

Reputation: 171

Depending on the file system and OS the path limit is changing. For Windows 7 it is 260 characters (starting from a drive letter). It includes drive letter, ":\" and conclusive NULL. For the rest of the path there is only 256 characters left.

Upvotes: 3

eau_de_Brute
eau_de_Brute

Reputation: 19

Can you try:

FormattingWbk.SaveAs Filename:= FilNameRq1

You're not hitting the character limit on this filename so I don't think that's a concern.

Is the subfolder you want to save to the same for all variables? If so we might be able to work with that by pre-defining that directory.

What's the full path?

How are you assigning a value to the variable? I would open your local window and step through to the variable definition. If you're not getting an error message it might have saved it to a different path or filename you didn't intend.

Upvotes: 0

Related Questions