none
Vendor dialog and my custom dialog display simultaneously at the same time on screen for users RRS feed

  • Question

  • n VS2013 vb.net for Office 2013

    The workflow is:
    1. User selects document template
    2. Call the vendors Save As dialog ie the document management dialog (DMS profile dialog)
    3. Document is saved in vendors system (into the document management system)
    4. Call/Show the specific templates custom dialog 

    My code references a vendors application dll library and calls their dialog boxes.
    C:\Program Files (x86)\NetDocuments\ndOffice\NetDocuments.Client.Common.dll

    C:\Program Files (x86)\NetDocuments\ndOffice\NetDocuments.Client.WordAddIn.dll

    As a proof of concept to get working and for ease of debugging the code I wrote the code in VBA Word template.

    The findings:
    Using VBA code successfully works and is in a sequential workflow ie
    I can call the vendors Save As dialog ie nd ShowSaveDialog() 
    The vendors Save As dialog displays ie nd ShowSaveDialog()  for user, all data fields are entered and the Save button is pressed
    The file is saved and the vendors dialog unloads
    Then the next line of vba code is executed, which displays a message box. This actually mimics the call/ shows dialogs for the custom template.

    When I convert the same code from vba to vb.net I get different and unusual results.  When I step through the code, the test results reveal:

    Code steps through fine with no errors (in Public Function SAPISaveDocAs(ByVal worddocument As WordDocument) As Boolean)

    However the vendors Save As dialog doesn’t display when actually called. Intially I thought this was due to a time lag as the vendors data store is located in the U.S data centre and Im located in Australia.

    However the vendors Save As dialog displays AND the custom template dialog displays simultaneously on screen at the same time.

    My code and workflow performs the following:

    In the library class call the vendors Save As dialog

    Public Function SAPISaveDocAs(ByVal worddocument As WordDocument) As Boolean

    ...perform other routines...

    Then the template dialog is called in ...

          Private Sub DocumentAdded(ByVal documentName As String) Handles m_libraryWord.DocumentAdded
            Logger.Log(Me.GetType(), "DocumentAdded", "Start", TraceEventType.Information)

            Try

                Select Case Config.UI_CONTAINER
                    Case Config.Containers.TASKPANE
                        Dim pane As CustomTaskPane = GetTaskPane()
                        If pane Is Nothing Then
                            pane = CreateTaskPane(True)
                        End If
                    Case Config.Containers.FORM
                        Dim newForm As Form = CreateTaskForm(True)
                        newForm.ShowDialog()
                End Select

            Catch ex As Exception
                Logger.Log(Me.GetType(), ex)
            End Try

            Logger.Log(Me.GetType(), "DocumentAdded", "End", TraceEventType.Information)

        End Sub


    Ive performed a code trace,and what appears to be occuring is...
    in Private Sub DocumentAdded
    on line newForm.ShowDialog()

    the code call ShowDialog() is a member of Microsofts System.Windows.Forms.DialogResult and both the vendor and my code are using it. I’m still diagnosing.

    Ive attached both working vba code and code in vb.net

    Has anyone experienced something similar and how did you resolve it.

    I was thinking if the vb.net code doesnt work I may need a routine from vb.net to call vba code to display vendors Save As dialog, then from vba module/template pass back to vb.net solution. However Ive not done this before.

    TIA

    --dd

    VBA working code calls NDSaveAs dialog.txt
    
    
    VBA code attach reference to vendors dll 'NetDocuments.Client.Common.tlb' type library in Word template
    
    C:\Program Files (x86)\NetDocuments\ndOffice\NetDocuments.Client.Common.dll
    C:\Program Files (x86)\NetDocuments\ndOffice\NetDocuments.Client.Common.tlb
    
    
    -------------------
    
    
    Option Explicit
    
    ' Add-in class declaration
    Dim oAppClass As New ThisApplication
    ' automation object for handling NdOffice events declaration
    Dim automationObject As NetDocuments_Client_Common.INdOfficeAddInUtilities
    
    
    Public Sub AutoExec()
        On Error GoTo ExitCode
        
        Set oAppClass.oApp = Word.Application
            
        Dim addIn As COMAddIn
        Set addIn = Application.COMAddIns("NetDocuments.Client.WordAddIn")
        Set oAppClass.addInUtilities = addIn.Object
        
        Exit Sub
    ExitCode:
        MsgBox "Error running AutoExec"
    End Sub
    
    
    
    -------------------
    
    
    Sub TestSaveDialog()
    
        ' dd invoke save doesnt call ND Save dialog and instead calls Microsofts default SaveAs
        'ActiveDocument.Save
    
        Dim addIn As COMAddIn
        Dim automationObject As NetDocuments_Client_Common.INdOfficeAddInUtilities
        'use WordAddIn, PowerPointAddIn, ExcelAddIn values
    
        Set addIn = Application.COMAddIns("NetDocuments.Client.WordAddIn")
        Set automationObject = addIn.Object
    
        Dim profile As NetDocuments_Client_Common.NdProfileAttributesCollection
        Set profile = New NetDocuments_Client_Common.NdProfileAttributesCollection
    
        Dim strDocName As String
        strDocName = "dd test doc"
    
            
        '' default to Home
        automationObject.ShowSaveDialog , profile, strDocName, "", "", ""
        
      
        MsgBox "nd Save As dialog called"
    
    
    End Sub
    
    
    
    

    'VBNet code calls NDSaveAs dialog
    
    
            ''' <summary>
            ''' Simple API DM Save Word Doc As
            ''' </summary>
            ''' <remarks>MS Word</remarks>
            Public Function SAPISaveDocAs(ByVal worddocument As WordDocument) As Boolean
    
                Try
    
                    If worddocument Is Nothing Then
                        Throw New ArgumentNullException("WordDocument passed was null")
                    End If
    
    
                    Dim ndo As Object
                    ndo = CreateObject("ndOffice.EchoingDataService")
                    Dim docInfo As Object
                    docInfo = ndo.getDocumentInfo(worddocument.Document.Application.ActiveDocument.FullName)
    
    
                    Dim MSWord As Microsoft.Office.Interop.Word.Application
                    MSWord = CType(GetObject(, "Word.Application"), Microsoft.Office.Interop.Word.Application)
                    MSWord.Visible = True
    
                    Dim addin As Microsoft.Office.Core.COMAddIn = MSWord.COMAddIns.Item("NetDocuments.Client.WordAddIn")
                    Dim ndDialog As NetDocuments.Client.Common.Interfaces.INdOfficeAddInUtilities = DirectCast(addin.Object, NetDocuments.Client.Common.Interfaces.INdOfficeAddInUtilities)
    
                    ndDialog = addin.Object
    
                    '' If document not saved in NetDocuments
                    If docInfo Is Nothing Then
    
                        If worddocument.Document.Application.Visible = True Then
    
                            '' default to nd Home
                            ndDialog.ShowSaveDialog(, , "", "", "")
    
                            'ndDialog.ShowSaveDialog(, , , , , , True)
    
                        End If
    
                    End If
    
    
                Catch ex As Exception
                    Logger.Log(Me.GetType(), ex)
                End Try
    
    
            End Function
    		
    	
    		
    		
    	Private Sub DocumentAdded(ByVal documentName As String) Handles m_libraryWord.DocumentAdded
            Logger.Log(Me.GetType(), "DocumentAdded", "Start", TraceEventType.Information)
    
            Try
    
                Select Case Config.UI_CONTAINER
                    Case Config.Containers.TASKPANE
                        Dim pane As CustomTaskPane = GetTaskPane()
                        If pane Is Nothing Then
                            pane = CreateTaskPane(True)
                        End If
                    Case Config.Containers.FORM
                        Dim newForm As Form = CreateTaskForm(True)
                        newForm.ShowDialog()
                End Select
    
            Catch ex As Exception
                Logger.Log(Me.GetType(), ex)
            End Try
    
            Logger.Log(Me.GetType(), "DocumentAdded", "End", TraceEventType.Information)
    
        End Sub
    
    

    • Edited by dd_ Tuesday, June 23, 2015 6:55 AM further edits
    Tuesday, June 23, 2015 6:45 AM

Answers

  • Hi,

    >>Code steps through fine with no errors (in Public Function SAPISaveDocAs(ByVal worddocument As WordDocument) As Boolean)

    However the vendors Save As dialog doesn’t display when actually called. <<

    Can the build-in dialog display correctly? If yes, I would suggest that you get more effective response from the verdor of this library to see whether this issue relative to it.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 24, 2015 5:17 AM
    Moderator

All replies

  • Hi,

    >>Code steps through fine with no errors (in Public Function SAPISaveDocAs(ByVal worddocument As WordDocument) As Boolean)

    However the vendors Save As dialog doesn’t display when actually called. <<

    Can the build-in dialog display correctly? If yes, I would suggest that you get more effective response from the verdor of this library to see whether this issue relative to it.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 24, 2015 5:17 AM
    Moderator
  • thanks
    Thursday, June 25, 2015 6:03 AM