LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel crashes with long file names

I am running a macro in Excel 2000 that does a "save as". If the file already
exists and the full filename (including drive and path) is greater than 149
characters, then Excel crashes. Apart from the obvious of shortening the
directory or file names, does anyone know how to stop this happening?

Example code below:

Private Sub CommandButton1_Click()

' This line works (149 characters)
ActiveWorkbook.SaveAs
"C:\abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst uvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr stuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.xls "

' This line works (150 characters) if file does not already exist
ActiveWorkbook.SaveAs
"C:\abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst uvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr stuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm.xl s"

' This line crashes (150 characters) if file already exists
ActiveWorkbook.SaveAs
"C:\abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst uvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr stuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm.xl s"

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
http://CannotDeleteFile.net - Cannot Delete File? Try Long Path ToolFilename is too long? Computer Complaining Your Filename Is Too Long? TheLong Path Tool Can Help While most people can go about their businessblissfully unaware of the Windo Max Loger Excel Discussion (Misc queries) 0 June 14th 11 04:30 PM
Removing duplicate records with long names in Excel 2007 Baran Excel Discussion (Misc queries) 2 February 17th 10 03:10 PM
I can't save long file names, only short one, how can I do this? short file names Excel Discussion (Misc queries) 0 January 3rd 06 05:13 PM
how do I choose only certain names from a long list in excel Mark Excel Programming 2 November 1st 05 03:48 PM
need to copy a long list of file names gilcola Excel Discussion (Misc queries) 6 August 19th 05 12:55 AM


All times are GMT +1. The time now is 10:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"