Author Topic: namespace mismatch error when exiting VBA script  (Read 3894 times)

0 Members and 1 Guest are viewing this topic.

GILESP

  • Newt
  • Posts: 42
namespace mismatch error when exiting VBA script
« on: February 12, 2015, 06:09:17 AM »
I have two very useful VBA projects that is starting to cause problems, one is used to perform various tasks on a list/batch of files, the other exports elements of a drawing to another file.

Both VBA scripts runs fine, and perform as expeced, however on completion and exiting I get the following error on the command line:
 
"\n*** INTERNAL ERROR: VL namespace mismatch\n"" type Y to reset:
 
Any thoughts on what might be causing this?  I suspect it is something to do with the code that opens and switches between drawings, as if I run the batch VBA without any files in the to-do list, it doesn't generate the error, however when I step through the code in the debugger, the error only pops up when the code finishes.

Here is a fragment of the code that actually opens and calls functions on the drawings from the batch project, there's other fluff around it that I don't think is relevant.:

Code: [Select]

    Dim oDWG As AcadDocument

    For i = 0 To Me.FilesToOpList.ListCount - 1
        BatchLaunchWin.Statusbox.Text = "Processing file " & CStr(i + 1) & " of " & BatchLaunchWin.FilesToOpList.ListCount
        DoEvents
        Set oDWG = Application.Documents.Open(Me.FilesToOpList.List(i, 1), ReadOnly)
        DwgChanged = False
       
        '##########################################do stuff here#########################################

        'Example function below, there are actually several..

        If BatchLaunchWin.SearchChkBox Then
            BatchLaunchWin.Statusbox.Text = "Changing Text.."
            DoEvents
            DwgChanged = ChangeText(oDWG, BatchLaunchWin.SearchTextBox.Value, BatchLaunchWin.ReplaceTextBox.Value)
        End If
       
         
        If ReadOnly Then
            oDWG.Close False
        Else
            oDWG.Close 'This will fail if the file is inadvertantly opened read only
        End If
       
        'emergency stop routine exits here
        If CrashStop Then Exit For
       
    Next i 'next drawing to process


And here is a code fragment from the exporting VBA:

Code: [Select]
    Dim ExportedDwg As AcadDocument

    SubjectDwg.Wblock ExportPath & "Backboxes\" & ExpBoxName, BoxSSet
    Report = Report & "Backbox file (flush) created with " & CStr(BoxSSet.Count) & " entities." & vbCrLf
    'open and saveas earlier filetype
    Set ExportedDwg = SubjectDwg.Application.Documents.Open(ExportPath & "Backboxes\" & ExpBoxName, False)
    ExportedDwg.Activate
    ExportedDwg.SaveAs ExportedDwg.FullName, ac2007_dwg
    ExportedDwg.Close False

In an ideal world, I'd Rewrite the code in VB.NET, but I don't have the time right now, and it's nice to be able to make 'per session' adjustments to the batch routine quickly without having to re-compile and such.

Can anyone shed some light on this? Its running on Acad 2015, and as far as I can recall, we didn't have this issue with 2013..
..END OF LINE..