I've posted this problem in a another thread that had a different subject.
I'm getting different results running this code in XM and in V8i.
In XM the result is Num=5, which is correct.
In V8i the result is Num=1, which is wrong. Apparently oLevels only gets level "Default" and ignores the others.
Sub NumLevels()Dim oFile As DesignFileDim FileNameDgn As StringDim Num As IntegerDim oLevels As LevelsFileNameDgn = "C:\Lixo\Test.dgn"Set oFile = OpenDesignFileForProgram(FileNameDgn, False)Set oLevels = oFile.LevelsNum = oLevels.CountEnd Sub
Any idea why?
Hi,
Try oFile..DefaultModelReference.Levels
--Robert
Robert,
Thanks for your help. That solved my first problem. The second problem is that after changing
a level's name, the changes are not saved. Below is the code that works in XM but doesn't works in V8i.
Do you know why?
Dim oLevel As Level
Set oLevel = oFile.DefaultModelReference.Levels.Find("A")
oLevel.Name = "B"
oFile.DefaultModelReference.Levels.Rewrite
LuĂs
I'm just guessing in the dark... Even with autosave turned on, you still have to manually save the OpenDesignFileForProgram. So I would first double check to make sure that the oFile is open for read/write (not read only), and then end it with oFile.Save . After that I would probably need to see the code to make any good guesses.
Problem solved with "oFile.Save".
My macro works under Excel. The purpose is to rename levels in a list of Dgn files.
For each level that is renamed it's necessary to process "oFile.DefaultModelReference.Levels.Rewrite" and "oFile.Save".
I'm just curious why this behaviour is different in XM and in V8i, but no problem.
Thanks for your help.
That question probably will remain a mystery. In a way I'm thankful for these changes--it shows us that vba is not dead yet--they're still working on it and making changes.
Who suggested that VBA might be dying?
For example, add CommandState.CommandName = "Robert" to one of your IPrimitiveCommandEvents classes. Look in the Edit|Undo menu once you've used your command. For something new in V8i, look at the IBatchConverterEvents object.
Regards, Jon Summers LA Solutions