Hi,
I have a macro for exporting my drawings to PDF.
But I want improve by adding the revision number only if the drawing has a revision number.
Actually (an extract of my macro with VBA)
'Set filename as original document filename. Dim FileName As String FileName = oDocument.FullFileName Dim Temp() As String Temp = Split(FileName, "\") FileName = Left(Temp(UBound(Temp)), Len(Temp(UBound(Temp))) - 4) 'Set the destination to save files. oDataMedium.FileName = "C:\Path...\" & FileName & ".pdf"
I wish this result :
If no revision : PartNumber.pdf
If revision : PartNumber_RevisionNumber.pdf
Thanks you,
Solved! Go to Solution.
Solved by Ktomberlin. Go to Solution.
This Should help.
Dim oRevNum As String
oRevNum = iProperties.Value("Project", "Revision Number") Dim oFileName As String
oFileName = ThisDoc.FileName(False) If oRevNum >= 1 Then oDataMedium.FileName = "C:\Path...\" & oFileName & "_" & oRevNum & ".pdf" Else oDataMedium.FileName = "C:\Path...\" & oFileName & ".pdf" End If
Thanks, but I think that working for iLogic, but don't working wih VBA.
How to get (Revision Number) with VBA (I'm a rookie with VBA)
Dim RevNum As (String ?) RevNum = (?)
Sorry, forgot i had to change that in VB
Dim oRevNum As String = GetPropertyValue(ThisDoc, "Inventor Summary Information", "Revision Number")
The "Revision Number" don't work.
If I use iLogic and not "VBA", because it's working better.
How to add a button in the ribbon ?
Like this : (with custom icon)
http://modthemachine.typepad.com/my_weblog/2008/11/creating-buttons-for-vba-macros.html
This works now for sure.
'Set the destination to save files.
Dim oDocRevision As Property
Dim Revision As String
Set oDocRevision = oDocument.PropertySets.Item("Inventor Summary Information").Item("Revision Number")
If oDocRevision.Value = 0 Then
oDataMedium.FileName = "C:\Temp\" & FileName & ".pdf"
Else
Revision = "_Rev-" + CStr(oDocRevision.Value)
oDataMedium.FileName = "C:\Temp\" & FileName & Revision & ".pdf"
End If
'Publish document.
Call PDFAddin.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub
Great, thank you very much.
Just a little correction.
I replaced :
If oDocRevision.Value = 0 Then
by
If oDocRevision.Value = "" Then