+ Reply to Thread
Results 1 to 13 of 13

not able to save pdf and it errors 400

  1. #1
    Forum Contributor
    Join Date
    10-24-2012
    Location
    San Diego, USA
    MS-Off Ver
    Excel 2019
    Posts
    849

    not able to save pdf and it errors 400

    hi, i have the following macro but its not saving pdf and it just gives out error 400 when ever i try to run it, i think its the part where the pdf is but i dont know enough to know what it is (the xlsm part works) if someone can help me recode it to save the pdf regardless of Saveas or save or save it, to always save the pdf file please.
    Please Login or Register  to view this content.

  2. #2
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: not able to save pdf and it errors 400

    I think you may need to attach your workbook so we can see what MakeFolders does and step through the code.
    Last edited by Croweater; 12-08-2022 at 03:22 AM.

  3. #3
    Forum Contributor
    Join Date
    10-24-2012
    Location
    San Diego, USA
    MS-Off Ver
    Excel 2019
    Posts
    849

    Re: not able to save pdf and it errors 400

    the code below is make folders, i didnt know it was relevant.

    i dont know what is need it to be able to read the code, since it has large sensitive information, i dont trust myself able to edit the sensitive infomration. but here is the attached sample workbook
    i think "folder1" and "folder2" is just a filepath
    Attached is the sample workbook..i think is all the code it needs.
    Attached Files Attached Files
    Last edited by chubbychub; 12-08-2022 at 04:17 AM.

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,002

    Re: not able to save pdf and it errors 400

    I think you need to specify which range you want to export as a PDF

    E.g.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-24-2012
    Location
    San Diego, USA
    MS-Off Ver
    Excel 2019
    Posts
    849

    Re: not able to save pdf and it errors 400

    thank you for the replies, i think i wasn't clear on what the problem is. When the macro runs its saves .xlsm and pdf. The problem is when i RE-OPEN the xlsm, then it will save the xlsm 'changes made on it' but not the pdf.. the PDF might need a if and else statement TO RESAVE. (this is were the error 400 happens)
    it will NOT resave the pdf, however the xlsm file will resaved any changes made to it.
    Last edited by chubbychub; 12-08-2022 at 11:55 AM.

  6. #6
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: not able to save pdf and it errors 400

    OK. This is what I did.

    1. Created a Customer sheet in your attached file and put some text in it
    2. Ran your macro (pressed the button)
    3. It saved the worksheet AND a PDF file in another sub directory with the name of your customer.
    4. I opened the NEW workbook in the customer sub directory and changed the text in the customer tab and pressed the button again.
    5. There were no errors. I checked the updated PDF in the customer directory and the changes I made were reflected in this PDF

    I repeated the process and all worked as expected.

    So I'm not sure why you are getting the error. Nothing wrong that I can see with the code, must be environmental/operational problem.

  7. #7
    Forum Contributor
    Join Date
    10-24-2012
    Location
    San Diego, USA
    MS-Off Ver
    Excel 2019
    Posts
    849

    Re: not able to save pdf and it errors 400

    what version of excel do you have? i have version 2019
    (not sure if its relevant but i have adobe acrobat PRO DC)
    i Ran it on another computer and it works fine as you said. , it does saves over it, but on this computer for some reason it wont save the pdf.
    could you point me to what should i be looking for or which way to look for please if you know)
    Last edited by chubbychub; 12-08-2022 at 08:40 PM.

  8. #8
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: not able to save pdf and it errors 400

    I'm using Office 365.

    Maybe you could amend your code to look for the PDF and if it exists, delete it before saving the new one?

  9. #9
    Forum Contributor
    Join Date
    10-24-2012
    Location
    San Diego, USA
    MS-Off Ver
    Excel 2019
    Posts
    849

    Re: not able to save pdf and it errors 400

    Ok, i learned how to step into (from you mentioning it), and ran into the below line (because if the name in "CustomerName" changes, then it should look for if it exist (i am not sure how to go about it or able to figure out myself) :
    Please Login or Register  to view this content.
    Last edited by chubbychub; 12-08-2022 at 09:40 PM.

  10. #10
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: not able to save pdf and it errors 400

    Here is a sub to check if a file exists and if it does, delete it;

    Please Login or Register  to view this content.
    So if you put DeleteFile(fName) just before you try to save your PDF, that should delete it first.
    Last edited by Croweater; 12-08-2022 at 10:11 PM.

  11. #11
    Forum Contributor
    Join Date
    10-24-2012
    Location
    San Diego, USA
    MS-Off Ver
    Excel 2019
    Posts
    849

    Re: not able to save pdf and it errors 400

    thank you Croweater! thank you Croweater!thank you Croweater!thank you Croweater!thank you Croweater! and thank you ByteMarks.
    I found the problem ! EVERYTHING YOU SAID Croweater, was RELEVANT for me to find the problem. it was a network drive how it was mapped. all these 5 years i had this problem and you pointed exactly to the right direction. (there was no one people would have known how the network and computer was setup from being online)
    Please allow me to explain why i have to praise you Croweater.
    All these years i had viewed the code, and other people recoding and recoding over and over again and OVER again and still did not resolve the problem.
    first when you mentioned 'step into it' i always saw that in vba editor but never knew how, so i googled it and followed some tutorial (yes for the past 3 sleepless nites been at it) and was able to run the code line by line and knew where the error was and where it stop.
    THEN you tested it and proved that there was nothing wrong with the code, and MADE me look and test on the network computers, which cause no errors as you said or else i would not have gone to test on other computers (because i ALWAYS thought it was just bad coding).
    then you POINTED that it must be in the 'ENVIROMENT', so i had installed excel 2016, excel 365 and reinstalled everything and was still the SAME ERROR, SO ..made me look at other things such as the drive.. only to discover how the mapped drives and network drives where different.
    This was a server computer that had the network drives mapped as local drives, there was no way anyone online would had known that and excel templates was also mapped from network drive. So i remapped the drive to open files from the network drive and KABOOM, no errors! All these years and finally the error is gone!
    thank you thank you thank you Bytemarks and Croweater!!!
    to make a long story short.....so basicly instead of REOPENING from local drive (D:\) .. i made a shortcut to network drive from desktop (Z:\)

    rep added and thread marked solved!
    Last edited by chubbychub; 12-09-2022 at 03:06 AM.

  12. #12
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: not able to save pdf and it errors 400

    WOW. This makes up for all the times people have taken the solution and said SFA!

    Thanks for the feedback/rep chubbychub.

  13. #13
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,002

    Re: not able to save pdf and it errors 400

    Glad you got it sorted.
    In slower time you might want to look at using the UNC path for the network. That way it doesn't matter what drive letter it's mapped to.

    If you have DFS, then you can find the drive in Explorer and right-click it to get the properties window. Then look at the DFS tab. The Referral list will show the UNC path; something like \\ServerName\\Foldername

+ 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] Save Macro - Avoid errors when /'s are present
    By NewYears1978 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-29-2021, 12:33 PM
  2. [SOLVED] Problem with save as function (getting errors)
    By joepekimo in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-25-2017, 01:12 PM
  3. [SOLVED] Save a worksheet off as it's own CSV without errors.
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2013, 11:52 AM
  4. My Word Macro creats Save w/ Errors grrr!
    By DadaaP in forum Word Formatting & General
    Replies: 1
    Last Post: 06-14-2013, 11:56 AM
  5. Save VBA errors & report them after macro completes
    By Philb1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2013, 01:00 AM
  6. Dealing with errors in file save macro
    By tcombest in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2012, 02:43 PM
  7. Save as Tab delimited file errors
    By askeladd in forum Excel General
    Replies: 2
    Last Post: 03-13-2007, 04:12 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