4 Replies Latest reply on Jun 28, 2018 12:06 PM by Ben Langdon

    Macro ( save as pdf) not working for all documents

    Ben Langdon

      So i have a bunch of documents that are very similar, just different sizes. so there is part 1, 2 and 3 of each assembly.. in some assembly's part 1 and 2 will save and not 3, and the other 1 won't save, and 2 and 3 do.

       

      the macro i gathered from other ones, takes the "PartNo" and put it as the title, saves as pdf, and puts it in a folder. the macro also says if i want to overwrite existing document (thanks to deepak gupta).

       

      The PartNo is in every document and i can't seem to find the difference between them. if you want to test it change where the save location is going in the code and it should work

        • Re: Macro ( save as pdf) not working for all documents
          Fifi Riri

          You're saving your drawings with a filename based on a custom property.

          If the file doesn't have this custom property, or if this string has characters not accepted for a file name, it will fail.

          Try to had this line at the end

           

               If boolstatus =0 then msgbox("Error saving " & filename)

            • Re: Macro ( save as pdf) not working for all documents
              Ben Langdon

              So that line does help in knowing that it isn't working instead of just getting no result. thanks

               

              i made sure that the PartNo is the one in the file properties and not sw-PartNo. the part numbers are all the same set of number and they don't look different from each document. no characters that cannot be used in the title of a file or anything like that. i made sure to do the same in the properties in the configuration in using as bill of materials and user specified name. the two documents look all the same and one still saves and the other doesn't

                • Re: Macro ( save as pdf) not working for all documents
                  Fifi Riri

                  Ok. Other thing you can try, is removing the line:

                  boolstatus = swExportPDFData.SetSheets(swExportData_ExportSpecifiedSheets, varSheetName)

                  it will print all the sheets (which is what you want anyway)

                   

                  Other than that : can you send the file that doesn't work?

                    • Re: Macro ( save as pdf) not working for all documents
                      Ben Langdon

                      ok so i think i found the problem

                       

                      swCustProp.Get2 "PartNo", value, resolvedValOut

                       

                      I actually don't want the "swCustProp", i want the configuration properties and get the "user specified name"

                       

                      so the ones it was working on had the same info in the "custom properties" as it did in the in the "configuration specific" and the "user specified name". i thought i was getting the "configuration specific" which is still fine as most of the couple hundred parts have the "configuration specific" info filled out, but really i need the "user specified name" for the configuration properties.