If the document has been saved, this will provide the path -- however if the document has not been saved, it will fail silently. You'll need to trap the failure and branch accordingly.
try
tell application "System Events" to tell (process 1 where frontmost is true)
set fmD to value of attribute "AXDocument" of window 1
end tell
end try