PDA

View Full Version : ActiveWorkbook.SaveAs not working with folder



alyson
08-08-2023, 06:12 AM
This seems insanely basic and something I have had work completely successfully in other files.


Dim organisationName As String
Sheets("Your Organisation").Select
organisationName = Range("C3").Value
Sheets("Your Organisation").Copy
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\1. Your Organisation\" & organisationName & " 22-23.xlsx"

The workbook just doesn't save; no errors pop-up. 1. Your Organisation is definitely the exact folder name I want and it already exists.

For example, if my workbook is saved in \Documents\Project\ then I want the new workbook to be saved as \Documents\Project\1. Your Organisation\organisationName 22-23.xlsx. If I remove & "\1. Your Organisation" then it does save, but as expected in the folder above (i.e. \Documents\ProjectorganisationName 22-23.xlsx)

I've also tried replacing "\1. Your Organisation" with just "" to try and force the file to at least save into the \Documents\Project\ folder. And again, it just doesn't save and there's no errors.

What am I doing wrong?

Aussiebear
08-08-2023, 12:51 PM
My first impression is that your system doesn't like "1. Your Organisation". Can you try saving again after creating a folder named "Your Organisation"?

Aflatoon
08-11-2023, 05:31 AM
Have you got On Error Resume Next somewhere in your code?

To save in the Project folder it would simply be:


ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & organisationName & " 22-23.xlsx"