Sign in to follow this  
Followers 0
walle

Get save path of a Word document?

1 post in this topic

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)

Share this post


Link to post
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
Sign in to follow this  
Followers 0