Method 'Saveas of object'_workbook' failed when trying to save workbook

I'm trying to save  a workbook in share mode.  I have this code but I'm getting a Method 'Saveas of object'_workbook' failed.  Here is the code:

Sub Save_Shared_Workbook()
ActiveWorkbook.SaveAs Filename:=" I:\Purch\TTE\CTF\Lupe\CTF Shortage Report Tool" & Format(Date, "MM-DD") & ".x_lsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False, AccessMode:=xlShared

End Sub
LUIS FREUNDAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieAnalyst Assistant Commented:
Luis

Is the file extension x_lsx you are using a typo?
LUIS FREUNDAuthor Commented:
I've changed that to.xlsx.

And I still get the error message
Lee W, MVPTechnology and Business Process AdvisorCommented:
Verify the path is accurate and that the file name does not contain invalid characters such as "\" or "/".

When you have problems like this best to put the file name in a variable and popup a message with that EXACT file name so you can confirm it's ok.  For example:
Sub Save_Shared_Workbook()
     TargetFileName = " I:\Purch\TTE\CTF\Lupe\CTF Shortage Report Tool" & Format(Date, "MM-DD") & ".x_lsx"
     msgbox TargetFileName   'Just for debugging purposes - remove once you've found the problem.
     ActiveWorkbook.SaveAs Filename:= TargetFileName, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False, AccessMode:=xlShared

End Sub

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Declare two string variables, one to hold the Path and another to hold the file name. That way it's easy to track if something goes wrong.

Please try this and see if that works for you...
Sub Save_Shared_Workbook()
Dim strPath As String, strFileName As String

strPath = "I:\Purch\TTE\CTF\Lupe\"
strFileName = "CTF Shortage Report Tool" & Format(Date, "MM-DD") & ".xlsx"

If Right(strPath, 1) <> "\" Then strPath = strPath & "\"

If Dir(strPath) = "" Then
    MsgBox "The Path " & strPath & " is not valid. Make sure that the Path exists.", vbCritical
    Exit Sub
End If

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=strPath & strFileName, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False, AccessMode:=xlShared

End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LUIS FREUNDAuthor Commented:
Thanks!  Line 16 is highlighted in yellow with same error code
LUIS FREUNDAuthor Commented:
I figured it out......
LUIS FREUNDAuthor Commented:
Thank you!
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome Luis!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.