Macro only works the 2nd time through the sequence

All,

I have attached a macro I was working on and cannot seem to get to work correctly. The macro is supposed to do a few things which I will try to explain as best I can.

Step 1: Check to see if the internal model within the drawing file is an assembly. If it is not exit the macro.

Step 2: Check to see if the file has been saved yet. If it has not been saved yet exit the macro.

Step 3: Find out the current "Revision" of the drawing. If it is "-" or "" or "-+" set the Revision to "0"

Step 4: Check to see if the file has been "published" at its current Revision. If it has been published exit the macro.

     We use the word "publish" here to mean that a .DWG, and .PDF file have been generated and placed in our Master Drawing Library.

Step 5: Publish all Necessary Files

     If a folder already exists for the assembly put the files in the folder. If a folder doesnt exist for the assembly already, create a folder and put the files inside the folder. The files should have the following format "15A-00001-0".

15A- stands for the year produced and the A is for assembly

00001 - is just a 5 digit serial number

-0 would be the revision

If I make a drawing for an assembly file and run the macro. The first time the macro runs it will publish files with the following format "14A-00065--" which is wrong. However if I simply rereun the macro and dont do anything at all it will publish correctly at 14A-00065-0. And if the file is currently Revision A,B,C.. it all works perfectly. However it seems "Step 3" is not working entirely correctly.

If you can lend a hand it would be greatly appreciated!!

Thanks,

Pencil

SolidworksApi macros