My macro runs fine when the solidworks application is visible but as soon as I change that it just saves blank files. Any ideas what could cause this?
This is just a limitation, certain APIs require graphics to work. I am afraid no much you can do about this. Try other options, such as LDR, detailing, lightweight, quick view. Depending on your API one of those could work for you and you can save some performance. But it might well be that the only option is to run the full application.
I second what Artem said. I tried in vain to do stuff with SW UI hidden, doesn't work. If you're coming from another CAD system that can do just about anything without a UI (as I did) you'll need to change your thinking on hiding the UI when using Solidworks API or macros.
Retrieving data ...