Export PDFs and DXFs based on a drawing sheet name

Hi there,

I've been trying to put together a macro by copying and pasting bits of code from other posted macros however I am unable to get the bits and pieces I needed to create the functionality I am after. I'm wondering if I can get some help here to create the correct macro.

1. Check if a drawing is open, if not then say 'please open a drawing'

2. Set save name and save path as the same as the drawing.

3. Check if the drawing has a drawing sheet with the name containing the word "flat" exists

     If yes,

     - export the "flat" named sheet as a DXF

     - export all other sheets as a single PDF (all sheets minus "flat" sheet)

     If no,

     - export all sheets as a single PDF

Much appreciated if I can get some help on this as I simply don't know how to code, I only understand the basic principles of it.

SolidworksApi macros