0

I have a working code where the user types the part number and the vba print's all pdf files inside the part number folder.

When there is only one version of the files it is working great, but when a new version is added, I can't figure out how to print only the new version of files.

For example: Part number 1012030. The folder would be "C\User\1012030\" then these files are inside:

1000210669_E.pdf (old)
1000210669_01.pdf (old) 1000210669_02.pdf (new)
1000210670_01.pdf (old) /1000210670_02.pdf (new)

the first revision is always "_E", then comes "_01"; "_02" and so on.. the code would look the the first pdf, loop until it finds the newest revision, print it, move to next file and repeat..

Cœur
  • 37,241
  • 25
  • 195
  • 267
Arthur
  • 1
  • You should share some code attempt before asking the question, or this would look like you're asking someone else to write the code for you. I suggest you start with [knowing how to loop through files in a folder](https://stackoverflow.com/a/10382861/3111149), then reading about [RegEx](https://stackoverflow.com/a/22542835/3111149) to recognize the last versions, then making a Function which takes in input the current directory, stores all last version file names in a list and return it for using it as you wish (print it, open them etc.) – Matteo NNZ Nov 06 '18 at 20:38
  • Or more easily, while looping through each file you could just [Split](https://www.techonthenet.com/excel/formulas/split.php) each file name by the character `_`, create a dictionary (with unique values) of each left side of the file name, and then for each of those files get the latest revision by simply reading at the largest numerical value of `Replace(Split(fileName,"_")(1), ".pdf", "")`. – Matteo NNZ Nov 06 '18 at 20:41

0 Answers0