Can one Read File name and path info for Missing Reference files with VBA

I have a macro that runs on each file open event. It checks on the active file's path and from that determines the project folder structure. It then assigns a few CFG variables that complete my MS_RFDGN paths. But sometimes, reference files show up as missing since the path resolution came too late. The fix is to reload the file. 

What I'd like to do, is determine if any are showing up as missing and then, if the new reference paths would resolve the missing reference, automatically reload the file. And if it would not, post something to the message center.

So I wanted to know if VBA can read info on missing reference files and are there limits a to what it can do?

Parents
  • Unknown said:
    What I'd like to do is determine if any are showing up as missing and then, if the new reference paths would resolve the missing reference, reload the file

    You can determine if an attachment is missing, as Robert suggests, but you can't reconstruct the path to the missing file (otherwise, MicroStation would already have done that and completed the attachment).

    What you can do is to search for a file using a configuration variable and then, if found, you know that you can attach it.  There isn't a VBA method that does what you need, but there is an MDL function: mdlFile_find.  Given a file name and a configuration variable, mdlFile_find attempts to find that file and returns its full path. 

    You can iterate your list of CFG variables, passing each to mdlFile_find, then stopping when you find a match.

    We show you how to use mdlFile_find.

     
    Regards, Jon Summers
    LA Solutions

  • I was going to use the File System Object to detect the missing file in one of the paths. I'll have to look at your link first - it may be more direct.

    The reason that MicroStation is not finding the files is that the reference file path variable is created using variables that have not been defined. My MVBA resolves the expected paths, based upon the project folder and then creates the variables. Sometimes, the reference files are found when a file is first opened. But other times they are not. My MVBA also opens a dialog box warning the user if there file is in a non-standard location.

    Most of the time the failure is due to users changing the project before opening a file. Or when changing projects without exiting MicroStation.

    But once the variables are assigned, reloading the file gives MicroStation a chance to locate them a second time, now that the variables are fully assigned. So my approach is to see if the missing reference files can now be located since the variables are now defined and pointing to the expected folders and if so, simply reload the file. And if the cannot be located, it usually means someone has attached a file from a non-standard location and that should be corrected. And I do not want to put MicroStation into a loop where it keeps reloading the active file if there are missing reference files, because sometimes we get files from other sources that have missing reference files we do not get.


    Charles (Chuck) Rheault
    CADD Manager

    MDOT State Highway Administration
    Maryland DOT - State Highway Administration User Communities Page

    • MicroStation user since IGDS, InRoads user since TDP.
    • AutoCAD, Land Desktop and Civil 3D, off and on since 1996
  • Unknown said:
    I was going to use the File System Object to detect the missing file in one of the paths. I'll have to look at your link first - it may be more direct

    The Microsoft File System Object (FSO) is an invaluable tool for VBA programmers.  It provides ways to analyse file & folder paths that are not available in VB/VBA/VBScript.  We wrote this article about the FSO; there are many more links on websites that deal with VB/VBA.

    However, the FSO is Microsoft technology.  It knows nothing of MicroStation and less about configuration variables.  The MDL function mdlFile_find is supported by Bentley Systems and does understand MicroStation configuration variables.  It is designed to help solve your sort of problem.

     
    Regards, Jon Summers
    LA Solutions

Reply
  • Unknown said:
    I was going to use the File System Object to detect the missing file in one of the paths. I'll have to look at your link first - it may be more direct

    The Microsoft File System Object (FSO) is an invaluable tool for VBA programmers.  It provides ways to analyse file & folder paths that are not available in VB/VBA/VBScript.  We wrote this article about the FSO; there are many more links on websites that deal with VB/VBA.

    However, the FSO is Microsoft technology.  It knows nothing of MicroStation and less about configuration variables.  The MDL function mdlFile_find is supported by Bentley Systems and does understand MicroStation configuration variables.  It is designed to help solve your sort of problem.

     
    Regards, Jon Summers
    LA Solutions

Children
No Data