简体   繁体   中英

ActiveX, VBScript, Word cannot create file

I am working with an application that uses VBscript/ ActiveX to embed Word in a browser. This application is not able to create the Word file to edit in the browser if it is not run as an administrator- instead I get and popup from Word saying: "Word could not create the work file. Check the temp environment variable"

I figured this is a permission issue, but I'm not sure how to fix it. First I was wondering where the file is being written to. I'm not sure if it's the TEMP variable for the current user (C:\\users\\chris\\appdata\\local\\Temp) or the actual environment variable (C:\\Windows\\TEMP) or the Internet Explorer temporary internet files directory (C:\\users\\chris\\appdata\\local\\Temp\\Temporary Internet Files).
Also, which user would need permission for the correct folder? Would it be the user that is running IE?

I get an error in the browser once the the Word file fails to load saying that the error is on line 60. The following is the relevant code from the page source:

<SCRIPT Language="VBScript">
    Sub InitWrapper()
    'MsgBox "First line of onLoad"
    oframe.EnableFileCommand(0) = False
    oframe.EnableFileCommand(1) = False
    oframe.EnableFileCommand(2) = False
    oframe.EnableFileCommand(3) = False
    oframe.EnableFileCommand(4) = False
    oframe.CreateNew "Word.Document"  --------------------------------This is line 60
    oframe.ReadRTF ( "{\rtf1\...fonttbl....*MORE HERE*......
    oframe.Activate
    End Sub

    sub Save_Data
        document.THEFORM.content.value = oframe.RTF
    end sub

        sub InsertString(str)
                dim doc
                Set doc = oframe.ActiveDocument
                doc.ActiveWindow.Selection = str
                doc.ActiveWindow.Selection.Collapse wdCollapseEnd
                'Paste directly
                'doc.ActiveWindow.Selection.Paste
                oframe.Activate
                document.THEFORM.content.value = oframe.RTF
        end sub

    sub wrapperUnload()
        oframe.Close
    End Sub
</SCRIPT>

Can anybody point me in the right direction as to what I should be looking for to fix this problem?

I saw a similar issue, when I am opening a word file embedded in IE browser through activeX, MS word throws the below error message in one of the pop-up boxes

Word could not create the work file. Check the temp environment variable

This is resolved by adding the web applications/site URL to the Trusted Sites List in the IE Browser Security settings.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM