john
john

Reputation: 191

"SaveAs" places file in a folder one level higher than expected

I am trying to save my file with a name as the value in range("A3") in sheets(2) into one of my folders called "my assignment".

It does not save into folder instead it saves it on my desktop.

\\fab2crp-nas1\home22\kkang2\Profile\Desktop\my assignment refers to folder directory where I want to save it.

ActiveWorkbook.SaveAs Filename:="\\fab2crp-nas1\home22\kkang2\Profile\Desktop\my assignment" & _
  ActiveWorkbook.Sheets(2).Range("A3").Value & "_Jramp" & ".xlsm", FileFormat:= _
   xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
   , CreateBackup:=False

Upvotes: 0

Views: 239

Answers (1)

DDV
DDV

Reputation: 2384

Assuming your file name in the cell doesn't start with \ so add that at the end of your hard coded file path: "\\fab2crp-nas1\home22\kkang2\Profile\Desktop\my assignment\".

The reason for this is because the last \ specifies the folder for the file to be stored in. I am not too sure on the specifics, but I am sure you can read up more on this in your OS documents.

To give an example:

If I have a file called Book1.xlsx and it is stored in a folder on the Desktop called Example then if I open the properties of that file to see its folder location I get the below:

enter image description here

So to continue on with this, in order for the program to locate/ access/ store your file, you would need to explicitly define the address. In my example:

C:\Users\deadevil\Desktop\Example\Book1.xlsx

Hope this helps clarify.

Upvotes: 1

Related Questions