Thanks to PTC support for explaining some things to me
Macro Add_FileName
Define h AS Integer
Define w AS Integer
Define el AS Element
w = activeDoc.window.pageX-2
h = 2
#Message "The height is " + h
#Message "The width is " + w
#Added below command to ensure number is placed on the Illustration number layer
ACTIVATE LAYER "Illustration Number"
Select none
Text Align Left
Text font 'Calibri'
Text size 6
Create Text w h stripext(activeDoc.name)
el = activeDoc.firstSelectedElement
el.text.backfill_color.type = "rgbValues"
el.text.backfill_color.rgb.red = 255
el.text.backfill_color.rgb.green = 255
el.text.backfill_color.rgb.blue = 255
el = el.nextSelectedElement
Rotate selection w h 90
Select none
End Macro