Showing results for 
Search instead for 
Did you mean: 

INSIGHT - Need Excel VB Macro to export Insight Data

Valued Contributor
Valued Contributor



does someone have code to export data from insight.

Tried something like this in excel, but does not work!

Dim objApplication As RevisionManager.Application

Dim objInsight As RevisionManager.Insight

Sub Main()


    Dim aListOfDocumentsToExport() As Object

    Dim ExportToLocation As String

    Dim SetDocToReadOnly As Boolean

    Dim OverWriteOption As Boolean


    Dim c As Collection

    Dim sr As Integer


    sr = FreeFile

'Filelist is tezt file, with a list of documents to export, like http://server/site/par1.par etc.

    FileList  = Sheets("Sheet1").Range("FileList").Value

    Destination = Sheets("Sheet1").Range("Destination").Value


    Open FileLIst For Input As #sr

    Dim l As String

    Dim Step As Integer

    Step = 100

    While Not EOF(sr)


        Call ConnectRevisionManager


        Set c = New Collection

        'Get list of items to export

        For i = 1 To Step

            If Not EOF(sr) Then

                Line Input #sr, l

                c.Add (l)

            End If


        ReDim aListOfDocumentsToExport(c.Count)


        ExportToLocation = Destination

        SetDocToReadOnly = False

        OverWriteOption = RevisionManager.OverWriteFilesOption.YesToAll


        Call objInsight.ExportDocumentsFromServer(c.Count, c, ExportToLocation, SetDocToReadOnly, OverWriteOption)


        Call DisconnectRevMgr


        c = Nothing




    Close (sr)


    End Sub

Sub ConnectRevisionManager()


    On Error Resume Next


    Set objApplication = GetObject(, "RevisionManager.Application")


    If Err Then

        ' Solid Edge is not running.  Clear the previous error.


        ' Start Solid Edge RevMgr.

        Set objApplication = CreateObject("RevisionManager.Application")


        ' Cannot start Solid Edge, so exit the program.

        If Err Then

            MsgBox "Cannot start Solid Edge.", vbCritical + vbOKOnly, "Open & Save"


        End If


    End If

    On Error GoTo 0


    ' Get reference to Insight object.

    Set objInsight = objApplication.Insight

End Sub

Sub DisconnectRevMgr()

    ' Release COM Objects.

    If Not (objInsight Is Nothing) Then

        objInsight = Nothing

    End If

    If Not (objApplication Is Nothing) Then

        objApplication = Nothing

    End If

End Sub


I need to use VB in excel since have no way to install Visual Studio Express or similar.

Thanks in advance for any info.

Best Regards



Posted by: Massimo Magris
Post date: 5/13/2010 8:41:32 PM


RE: INSIGHT - Need Excel VB Macro to export Insight Data

Valued Contributor
Valued Contributor



Can you be little more specific about what exactly you are trying to achieve, what problem you are facing with the current code and where (the specific line in the code if possible)?



Posted by: Sanjay Kulkarni
Post date: 5/19/2010 12:21:20 AM