VBA Macro "FENCE FILE" Does not working properly

Hi, I'm using this forum a lot to answers my doubts with old posts (thank you a lot), however I don't found nothing about it. 

I'm creating a macro to create a new .dgn file using Fence File (part of drawing that I need). For do it manually is working good.  However, than I need use as automation, after call command "FENCE FILE", a windows "Save Fence Contents As" is showing, but the folder and name does not fill automatically by Macro, and if I add a name manually, and press SAVE, window close and files does not save.

Any one knows about that? and How to create a work around to solve this issue?

I'm using the follow script.  

Function ExportSheets()
    Dim modalHandler As New BmrCGMModalHandler
    
    AddModalDialogEventsHandler modalHandler
    CadInputQueue.SendKeyin "FENCE FILE"
    RemoveModalDialogEventsHandler modalHandler
End Function

With Class created as bellow

Implements IModalDialogEvents
Private Sub IModalDialogEvents_OnDialogClosed(ByVal DialogBoxName As String, ByVal DialogResult As MsdDialogBoxResult)

End Sub

Private Sub IModalDialogEvents_OnDialogOpened(ByVal DialogBoxName As String, DialogResult As MsdDialogBoxResult)

    Dim NewPoint As Point3d
    
    CgmDir = ActiveDesignFile.Path + "\"
    NewPoint.X = ExportNewForm.IDLocationX.Caption + ExportNewForm.NewSheetLocationX.Caption
    NewPoint.Y = ExportNewForm.IDLocationY.Caption + ExportNewForm.NewSheetLocationY.Caption

        Dim esc As ElementScanCriteria
        Set esc = New ElementScanCriteria
        esc.ExcludeAllTypes
        esc.IncludeType msdElementTypeText
            
        Dim ee As ElementEnumerator
        Set ee = ActiveModelReference.Scan(esc)
        
        Do While ee.MoveNext
            If ee.Current.AsTextElement.Origin.X > (NewPoint.X - 10) And ee.Current.AsTextElement.Origin.X < (NewPoint.X + 10) Then
                fileName = ee.Current.AsTextElement.Text
            End If
        Loop
        
    If DialogBoxName = "Save Fence Contents As" Then
        CadInputQueue.SendKeyin "MDL COMMAND MGDSHOOK,fileList_setDirectoryCmd " & CgmDir

        CadInputQueue.SendKeyin "MDL COMMAND MGDSHOOK,fileList_setFileNameCmd " & fileName & ".cgm"

    '   Remove the following line to let the user close the dialog box.
        DialogResult = msdDialogBoxResultOK
        
    End If  ' Save Fence Contents As
    
End Sub

I'm using Microstation Connect Edition Release 13

Thank you.
Naime Andere

Parents Reply Children