VBA error "No such application" when placing cell with tag set

Hey all. I've run into a problem and I hope someone here can help me. I've got a macro written that places a cell and then automatically sets the tags. However, when I call CreateCellElement2(), I'm getting a run-time error with code -2147218383 (80040c31) and text "No such application".

I searched online for that particular text, and sure enough, the first result was right here on this forum, from a few years back. But the person who made that posting never got an answer, they just settled for using key-ins. In my case, this process is designed to run multiple times, so key-ins aren't very attractive. Below is the code where I'm getting the error. For the record: ZP() is just an alias for Point3dZero. I've verified that the cellName var gets the correct cell name, that the correct cell library is attached, etc, etc.

'select which block
    Dim cellName As String
    cellName = Left(vp.cellName, Len(vp.cellName) - 3)
    
    'set up and create the cell
    Dim cellBlock As CellElement
    Set cellBlock = CreateCellElement2(cellName, ZP(), Point3dOne(), True, Matrix3dIdentity())
    'might need to specify the sheet name with activedesignfile.models(sheet name)
    ActiveModelReference.AddElement cellBlock
    cellBlock.Redraw msdDrawingModeNormal
    cellBlock.Rewrite



Parents
  • Hi Darin,

    to understand your situation better I have a few questions:

    • What MicroStation version do you use?
    • And I guess this code is run directly from MicroStation, not from other externall app like Excel?
    • Not probably related to the problem, but why do you use Redraw (which is useless in XM Edition and V8i) and Rewrite?

    With regards,

     Jan

  • 1) V8i SS3
    2) Yes, it's not being run through any other application.
    3) I'm unsure why you say this, because without fail, if I do not call .Redraw, any element I create or modify using VBA does not appear or update on the screen. I have several resources, including "Learning MicroStation VBA", "MicroStation VBA Essentials" and "MicroStation VBA for Advanced Users", all of which indicate that you must call .Redraw in order to update any changes (including creation) you make to an element. Also, I have found that calling .Rewrite often helps with a frequent issue I've experienced in which random lines of VBA will be skipped at run-time in more complex scripts. (This is an issue with VBA in general, not Microstation as it occurs in almost every application that includes the VBA IDE).
  • Because it seems web player does not managed the video correctly, I attached is as zip file.

    Regards,

      Jan

    places_shape.zip

  • I see that, and it does not match with my experience or documentation at all. I cannot explain it except through your earlier suggestion that perhaps I am using an out-of-date library (and out-of-date documentation). However, I am unable to determine how to even go about updating my dll's, due to Bentley's tight-lipped nature when it comes to documentation and answering questions. If you know, I would greatly appreciate you telling me. It certainly couldn't hurt, and might well fix my problem (as well as a number of other problems I worked around rather than posing here).
  • Unknown said:
    I am unable to determine how to even go about updating my dll's

    I guess the first step is to check what is referenced to MicroStation VBA project in VBA Editor:

    MicroStation V8i versions have to reference Bentley MicroStation DGN 8.9 Object Library, I recommend also to check if its path is correct.

    I am not sure if there is some other simple test that can be done.

    You can try to download Bentley Prerequisities installation and to run it, because it will check and re-register everything related to MicroStation VBA. I took the link from this discussion.

    With regards,

      Jan

  • Jon Summers,
    I am unable to reply directly to your post, so please excuse my lack of quotations for clarity.

    1) Yes, it works perfectly if the cell does not have a tag set. It also works perfectly in other VBA modules in which I have used that method. This particular module has Option Base 0 set, though when I tried removing that and reworking my arrays, it did not seem to help. There is, furthermore, a truly bizarre occurrence happening which I just noticed this morning which I will describe below.
    2) Yes, though it is defined through a DGN library. I have tried the code in a DGN file that has the tag set explicitly defined, and it produces the same error.

    The Bizarre occurrence I mentioned is that I have found that if I run this module enough times (as would happen during debugging with a particularly intractable issue), MS will eventually strip all the tags and the tag set from the cell, replacing the tags with text elements containing the default value of the tag. I have tried this with several different cells, and it does it to all of them. I have no explanation for this, and have never seen anything like it.

    On to your next questions, in answer to both: I have documentation for those methods in my help file, though ManipulateAsElement is listed as a property (a read/write boolean, to be precise).

    Jan Slegr,

    Thank you for that. I will try to run the prerequisites installer again and see if that helps at all.

  • Unknown said:
    I will try to run the prerequisites installer again and see if that helps at all.

    Can you share a capture of your Reference dialog (as I did) for VBA project you have problems with?

    Maybe it will help somebody to investigate where the problem can be.

    With regards,

      Jan

  • Unknown said:
    I have documentation for those methods in my help file

    Well, your help is up to date.  To test whether your VBA installation is also up to date, add some code that uses one of the later methods to your project, and see if the IDE complains.  For example...

    Sub VersionTest ()
      '  If VBA doesn't complain, then you're OK
      Dim oSmartSolid As SmartSolidElement
    Set oSmartSolid = CreateCone (Nothing, 1.0, 1.5, 2.0) End Sub

     
    Regards, Jon Summers
    LA Solutions

  • Unknown said:
    add some code that uses one of the later methods to your project, and see if the IDE complains. 

    I like this way! :-)

    In MicroStation V8 2004 Edition that uses Bentley MicroStation DGN 8.0 Object Library, it ends with this error (because SmartSolidElement was introduced in V8i using DGN 8.9 Object Library):

    Regards,

      Jan

  • Hopefully, the forums will post my response this time. The following is copied and pasted from an email I just sent to Jon Summers:

    I am Darin Rodberg, the member of the Bentley forums whom you and Jan Slegr have been attempting to help. I am unable to currently use the forums to post replies in any form, which is why I am sending you this email. I also cannot locate Jan’s email, as I get a 503 error whenever I try to access his blog or website. For the record, this appears to be a technical difficulty, as it is consistent across different browsers and different computers. I truly have never encountered such pervasive difficulties before with any software developer, to the point where I am currently researching whether or not there is malware of the “annoyanceware” variety directed at Bentley with which my computer may be infected.

    If you would be so kind, please inform Jan that my references are the same as his, except in terms of their priorities. I will modify those priorities and restart, to see if that helps.

    Please also accept and convey to Jan my gratitude for the help you two have been providing me. I’m quite sure my frustration comes through at the forums and in this email, but that frustration is exclusively directed at Bentley, their software developers, customer services and website. The members of the forum have been nothing but helpful to me. I will do so myself if and when I find the forums to be functional.

    As a final note (this is no longer from the emai), I am capable of using vba to implement SmartSolids. It produces no error.

  • I am finally able to get the advanced reply editor to work. Here is the screenshot of my references dialog. Note that the "PCS_Tools" entry is a vba module which contains a few geometric functions, and a few aliased microstation functions, such as XY() for Point3dFromXY() and ZP for Point3dZero(). Only the two aliases I gave as examples are used in this module.

    Also, I have a question: Does the title of this forum contain chinese characters for anyone but me?

  • Unknown said:
    Does the title of this forum contain chinese characters for anyone but me?

    Yes, that is a puzzle.  It's an image rather than character glyphs...

    I usually use the other Programming Forum.  I don't know why this one exists.

     
    Regards, Jon Summers
    LA Solutions

Reply Children