ChangeFileOpenDirectory error 4172 when savpath is in SharePoint Word 2010 RRS feed

  • Question

  • Hi

    We are going to uppgrade to Windows 7, Office 2010 and i am testing the environment. The problem I have is when setting the savepath with ChangeFileOpenDirectory to a sharepoint path. If i open the SaveAs dialog and paste the path to then namefield it works but if i use changeFileOpenDirectory I get the 4172 error.

    Anyone knowing an answer


    Thursday, February 23, 2012 10:32 AM


  • Hi,

    Two things:

    1. You should avoid using such method. As you are working with automation, and the ChangeFileOpenDiectory method works for asking user to inputting file location. You should directly call SaveAs2 method to upload your Word document.

    2. The URL you input might contain some blank space, the procedure is unable to read it, you should replace all black space with "%" to make the URL work. Check the following VBA code:

    Sub upload()
        Dim doc As Document
        Set doc = ThisDocument
        Dim fileName As String
        fileName = "http://blablabla/sites/DefaultCollection/testproject/Office 20Dev 20Lib/" & doc.Name
        Dim SaveName As String
        SaveName = Replace(fileName, " ", "%")
        doc.SaveAs2 SaveName, wdFormatXMLDocumentMacroEnabled
    End Sub

    I hope this helps.

    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us

    Friday, February 24, 2012 3:24 AM