Jump to content

Get save path of a Word document?


Recommended Posts

I have been trying to collect the save path of a Word document. So far, no luck.

Any idea?

Part of the script.

; For each Word window
        $oDoc = ""
        $oWordApp = ""
        $handle = WinGetHandle("classname=OpusApp", "")
        If $handle = "" Then ExitLoop
        $oWordApp = _WordAttach($handle, "HWND")
        If Not @error Then
            ; For each DOC
            $colDocs = _WordDocGetCollection($oWordApp, -1)
            If @error = 0 Then
                For $oDoc In $colDocs
                    _WordDocSave($oDoc)
                    If @error = 1 Then ; Check if savepath is selected.
                        RegWrite('HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce' , 'WordDoc' & $i, 'REG_SZ', '"' & @ScriptDir & "\Test" & $i & ".doc" & '"')
                        _WordDocSaveAs($oDoc, @ScriptDir & "\Test" & $i & ".doc")
                        $i += 1
                    EndIf
                Next
            Else
                ;MsgBox(16, "Error", "Error retreiving collection of Docs")
                ExitLoop
            EndIf
        Else
            ;MsgBox(16, "Error", "Error attaching to Word window by HWND")
            ExitLoop
        EndIf
        _WordQuit($oWordApp)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...