Are you recording this as a VBA macro? Could you paste your code or attach the macro file?
As soon as the macro hits the first locating dimension it stops and errors.
What is the error message when your macro stops?
Is it because the dimension is to something that is not in the sketch or to two entities?
I don't have a whole lot of experience with DisplayDimensions or Dimensions in the Solidworks API. I'm starting to dive into those right now actually. From my limited experience with them, I've done several of the things that the documentation recommends not to do and I have not observed any exceptions or crashes.
It might be easier if you can use your macro (with userform) to get/retrieve parameters or variables (whatever you want to call) from the equation. and the sketch dimensions should be linked to equation variables. then you don't have to worry about the dimension or sketch names
Unless you share the macro and corresponding file, it would hard to debug.
On other side, you may want to try/use the DriveWorksXpress (free add-in for design automation since 2008 with every seat of SOLDIWORKS). It would be fairly easy to use and not only model (part and assemblies) but you can also get the drawings made.