+ Reply to Thread
Results 1 to 3 of 3

Getting error 400 when click the save file button

  1. #1
    Registered User
    Join Date
    07-23-2013
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    2

    Getting error 400 when click the save file button

    I am building a simple excel template that will save and clear a Purchase Order.
    However, it always return the error 400 when i click the Save and Clear button which will save the purchase order to public drive. Also, the file path i save is changed to "P:\Sam PO\PO" & Range("L2").Value & ".xlsx" from "K:\Sam PO\PO" & Range("L2").Value & ".xlsx", but I didn't change it myself.

    here is my code for the save and clear button, could anyone please tell me what is the cause of error 400 and is there anything wrong with this code?
    I tested it on my local environment, I didn't experience any error.

    Sub NextInvoice()
    Range("L2").Value = Range("L2").Value + 1
    Range("B22:L51").ClearContents
    End Sub

    Sub SaveInvWithNewName()
    Dim NewFN As Variant
    ' Copy Invoice to a new workbook
    ActiveSheet.Copy
    NewFN = "K:\Sam PO\PO" & Range("L2").Value & ".xlsx"
    ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
    ActiveWorkbook.Close
    NextInvoice
    End Sub

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Getting error 400 when click the save file button

    Include a \ at the end of K:\Sam PO\PO...

    ...unless the first value of Range("L2") is a \

    Why is NewFN dimmed as variant instead of string?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    07-23-2013
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Getting error 400 when click the save file button

    thank you so much. we figured out why it is causing the error 400 after we add the error catch. it is caused by the local drive.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Compile Error: Method or data member not found when i click Save button...
    By aditbaco in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-15-2013, 07:11 AM
  2. How to auto click the save as button in IE 9
    By zalora in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-13-2013, 06:43 AM
  3. [SOLVED] Click button to save as file name --> open message if range is 1
    By debbiesh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-04-2012, 03:05 PM
  4. Click a button, auto-save a copy of the .XLS file to a specified location?
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2011, 12:45 PM
  5. Prevent to click save button
    By accessman2 in forum Excel General
    Replies: 3
    Last Post: 04-22-2007, 06:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1