Word宏无法保存文件名> 255个字符

时间:2009-09-25 09:33:34

标签: vba ms-word

我在Word Macro中有这个

ActiveDocument.SaveAs FileName:="D:\\GrooveAndRock\\GrooveAndRock\\GrooveAndRock\\GrooveAndRock\\GrooveAndRock\\GrooveAndRock\\GrooveAndRockAndRoll\\GrooveAndRockAndRoll\\GrooveAndRockAndRoll\\GrooveAndRockAndRoll\\GrooveAndRockAndRoll\\GrooveAndRockAndRoll\\Ug F Blug and Bug f Goo - Blank Address - 2009-09-25 093614.doc", FileFormat:=wdFormatDocument, _
     LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
    :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
    SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
    False

(注意长文件名)

当我运行它时,我得到: “运行时错误'9105':

字符串长度超过255个字符“

字自动化是否真的无法保存长文件名?这是一个非常严重的限制,但谷歌搜索错误却没有带来什么......

有解决方法吗?

怎么回事!??!?

困惑..

4 个答案:

答案 0 :(得分:2)

尝试使用dir函数进入所需的文件夹,然后保存:

ChDir "D:\\GrooveAndRock\\GrooveAndRock\\GrooveAndRock\\GrooveAndRock\\GrooveAndRock\\GrooveAndRock\\GrooveAndRockAndRoll\\GrooveAndRockAndRoll\\GrooveAndRockAndRoll\\GrooveAndRockAndRoll\\GrooveAndRockAndRoll\\GrooveAndRockAndRoll\\"

ActiveDocument.SaveAs FileName:="Ug F Blug and Bug f Goo - Blank Address - 2009-09-25 093614.doc", _
    FileFormat:=...

答案 1 :(得分:1)

答案 2 :(得分:1)

答案 3 :(得分:0)

您可以通过将路径转换为旧的8.3格式来解决此问题:

    strFolder = "D:\GrooveAndRock\GrooveAndRock\GrooveAndRock\GrooveAndRock\GrooveAndRock\GrooveAndRock\GrooveAndRockAndRoll\GrooveAndRockAndRoll\GrooveAndRockAndRoll\GrooveAndRockAndRoll\GrooveAndRockAndRoll\GrooveAndRockAndRoll"
    ActiveDocument.SaveAs _
        FileName:=CreateObject("Scripting.FileSystemObject").GetFolder(strFolder).ShortPath & "Ug F Blug and Bug f Goo - Blank Address - 2009-09-25 093614.doc", _
        FileFormat:=...