How to?: Ensure code only operates on model reference with specified name?

Hi,

As the title says I am wondering how in code I can target a specific model reference (ignoring all other model references in a designfile).An existing Macro I am trying to modify uses this:

Set oDgnFile = OpenDesignFileForProgram(oFile.Path, False)
For modelCount = 1 To oDgnFile.Models.Count
                    If oDgnFile.Models(modelCount).Type = msdModelTypeSheet Then
                        myModel = oDgnFile.Models(modelCount).Name
                    ElseIf oDgnFile.Models(modelCount).Type = msdModelTypeNormal Then
                        myModel = oDgnFile.Models(modelCount).Name
                    End If
Set oEnumerator = oDgnFile.Models(myModel).Scan(oScanCriteria)

What I am wanting is for my oEnumerator to only scan on a modelreference called Sheet. I know of the .Name property and its probably very easy to do but I can think how to put it all together.

Any help is appreciated.

  • Hi Gerald

    Thanks for the example. I think before I misunderstood your first post, I was thinking that your example line  ProcessMyModel oModel

    contained additional code that you had not yet revealed. However I now realise that you were recommend that I encapsulate my succeeding code within the new sub. So having clarified all of that, I have done just that and it now seems to be on only the sheet reporting as desired. No doubt further quirks await but thay will save for another day.

    Thanks again guys