Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
cody_evjen
949 Views, 5 Replies

Revision History Export with iLogic

Can anyone help me with some code to Export a revision history table. I know how to designate the location and filename but I cannot seem to figure out the command line that actually executes the exportation.

End goal is to get the whole revision history table into an excel doc named the same as the file it came from via one button in a form.

GeorgK
in reply to: cody_evjen

Hi,

This rule exports the revision table to excel

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oOptions As NameValueMap 'see below for additional options
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Value("AutoFitColumnsWidth") = 1

Dim oRevTable As RevisionTable
oRevTable = oDrawDoc.ActiveSheet.RevisionTables.Item(1)

oRevTable.Export(ThisDoc.PathAndFileName(False) & ".xls", kMicrosoftExcelFormat,oOptions )

For more information about the options you can add:

 

RevisionTable.Export Method

RevisionTable.Export Method

Parent Object: RevisionTable

Description

Saves the revision table to an external file.

Syntax

RevisionTable.Export( FileName As String, FileFormat As FileFormatEnum, [Options] As Variant )

Parameters

Name Description
FileName Input string that specifies the file name to export the revision table to.
FileFormat Input FileFormatEnum that specifies the file format to save to.
Options Optional input NameValueMap object that specifies additional options for export. Valid inputs are listed in the table below.
Name Value Type Valid for export formats
TableName String kMicrosoftExcel, kMicrosoftAccess
ExportedColumns String containing semicolon separated column titles All
IncludeTitle Boolean kMicrosoftExcel, kTextFileCommaDelimited, kTextFileTabDelimited, kUnicodeTextFileCommaDelimited, kUnicodeTextFileTabDelimited
StartingCell String kMicrosoftExcel
Template String kMicrosoftExcel
AutoFitColumnWidth Boolean kMicrosoftExcel

 

 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"

I tried the ilogic. I get this pop-up.

Now i am able to get around this window and it asks me to make a save as copy and then asks me for a location.

Works but just as many steps as export clicking the rev table.

I know how to point a directory but i can seem to get around this error and it is stopping the file from exporting to a location i want in one click.

 

Thanks for the help this far though, closest I have gotten in over a year.

 

 

Capture.JPG

 

 

Hi,

 

I've noticed that the drawingdocument should be saved first, otherwise it cannot create a file and then you get the error.

You could workaround by saving the excel in your workspace.

The other problem is that the xls extension should be xlsx

Then it works perfect

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oOptions As NameValueMap 'see below for additional options
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Value("AutoFitColumnsWidth") = 1

Dim oRevTable As RevisionTable
oRevTable = oDrawDoc.ActiveSheet.RevisionTables.Item(1)

oRevTable.Export(ThisDoc.PathAndFileName(False) & ".xlsx", kMicrosoftExcelFormat)

 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"

This did work, Thanks!

Still wasn't able to get the auto-fit to work for some reason but that is super minor.

If anyone is looking for the expanded ilogic here is how to give it a file name and a location.

 

SyntaxEditor Code Snippet

Try
'oPath = set Export Path location
    oPath = "C:\_CADD"

'Set Values
    'Defines filename. Is directly linked to Part Number for Drawing.Sets other data values.
    oTableNumber = iProperties.Value("Project", "Part Number")
    oFileName = ThisDoc.FileName(False) 'without extension
    oDocument = ThisApplication.ActiveDocument
    oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
    oRevTable = oDocument.ActiveSheet.RevisionTables.Item(1)
    oOptions = ThisApplication.TransientObjects.CreateNameValueMap
'get target folder path
    oFolder = oPath & "\" & "For_Import"
'Check for the Target folder. If it exists, do nothing. If it does not exist, create it.
If Not System.IO.Directory.Exists(oFolder) Then
    System.IO.Directory.CreateDirectory(oFolder)
End If

'Set the target file name
oDataMedium.FileName = oFolder & "\" & oTableNumber & "-TempRevTable" & ".xlsx"
oExportName = oDataMedium.FileName

'Export Rev Table document
oOptions.Value("AutoFitColumnsWidth") = 1
oRevTable.Export(oExportName, kMicrosoftExcelFormat,oOptions)

Beep()
i = MessageBox.Show("Revison Table successfully exported!", "Revison Table Export", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
Catch
MessageBox.Show("No Revison Table Found.", "iLogic - Warning")
End Try