Bring Window To Front

Maybe try this macro from @JMichaelTX? It's generally worked well for me.

As for why you're getting the error in the first place, this may not be necessary if you've found a workaround by just opening the file as part of the macro, but if you still want to figure out why your original idea of bringing the window to the front isn't working, try posting your full macro here so we can get a better idea of what may be going on.