I know this is something very easy, i've searched and tried several things and can't find the solution.
I get the "End of Statement Expected" error for the Dim lines with following ilogic but it might be related to the first line because that line on its own results in a EarlyRev value of -1 no matter what value is stored in oRevNum. There might be a better solution but all i really want to do is move the previous revision to the obsolete folder prior to making the pdf. Also, how do i set the saveas command to overwrite if the existing file already exists?
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
'Move Prior Rev to Obsolete
If oRevNum>=1 Then
Dim EarlyRev AsString= oRevNum - 1
MessageBox.Show("Did it work"&EarlyRev)
Dim FileCurrent AsString="P:\" & PDF_Folder "\" & FileName & " REV" & EarlyRev & ".pdf"
Dim FileObs AsString= "P:\" & PDF_Folder & "\Obsolete\" FileName & " REV" & EarlyRev & ".pdf"
System.IO.File.Move(FileCurrent, FileObs)
EndIf
Solved! Go to Solution.
Solved by Ktomberlin. Go to Solution.
Dim FileCurrent As String = "P:\" & PDF_Folder & "\" & FileName & " REV" & EarlyRev & ".pdf" Dim FileObs As String = "P:\" & PDF_Folder & "\Obsolete\" & FileName & " REV" & EarlyRev & ".pdf"
try these changes please.
That did get rid of the statement errors, Thank you. I see the missing "&"s. I'm still having issues when the pdf file already exists for the current Rev. It doesn't overwrite a new copy of the pdf. Anyone have thoughts on this? I thought the intial version of post PDF creation ilogic did over write or at least gave you a yes/no dialog.
I did solve my Earlyrev variable issue, within the if statment i had to define the the oRevNum again (oRevNum=iProperties.Value("Project", "Revision Number") since apparently how i've got it defined above isn't global.
I've also got it moving the old rev file now with.
oRevNum=iProperties.Value("Project", "Revision Number")
oFileName=ThisDoc.FileName(False)
If oRevNum>=1ThenDimEarlyRevAsString=oRevNum-1
' Debug MessageBox.Show("Did it work? " & EarlyRev)DimFileCurrentAsString="P:\"&PDF_Folder&"\"&oFileName&" REV"&EarlyRev&".pdf"
DimFileObsAsString="P:\"&PDF_Folder&"\OBSOLETE\"&oFileName&" REV"&EarlyRev&".pdf"
System.IO.File.Move(FileCurrent, FileObs)
@Ktomberlin wrote:Also, how do i set the saveas command to overwrite if the existing file already exists?
You would need to delete the old file first. Like so.
Dim FileCurrent As String = "P:\" & PDF_Folder & "\" & FileName & " REV" & EarlyRev & ".pdf" Dim FileObs As String = "P:\" & PDF_Folder & "\Obsolete\" & FileName & " REV" & EarlyRev & ".pdf" If System.IO.File.Exists(FileCurrent) Then System.IO.File.Delete(FileCurrent) End If System.IO.File.Move(FileCurrent, FileObs)
I figured out that since I had windows explorer open to the folder I was creating the pdf's in. It was failing due to windows explorer accessing the file for the preview. Since closing windows explorer it now works. I'm just now adding the code to check to make sure the file can be rewritten and post a msgbox if it can't instead of crashing. I'm sure its not the cleanest code but its working as desired. Thank you for the help today.