TAGS :Viewed: 6 - Published at: a few seconds ago

[ Word macro cannot save filename > 255 characters ]

I have this in my 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

(note the long filename)

When I run it, I get : "Run-time error '9105':

String is longer than 255 characters"

Is it really the case that word automation cannot save long filenames? This is a pretty serious limitation, yet a google search on the error has brought up nothing..

Is there a workaround?

Whats going on!??!?

Confused..

Answer 1


Try using dir function to get into the folder you want and then save it.

Answer 2


That's a limitation in Windows:

http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maximum_path_length

Answer 3


That is it: http://msdn.microsoft.com/en-us/library/zw949162.aspx