Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Excel crashes with long file names

Hi Confuscious,

Apart from the obvious of shortening the
directory or file names, does anyone know how to stop this happening?


Delete the file you're overwriting first:

On error resume next 'In case file is not there
Kill "c:\YaddaYadda.xls"
Activeworkbook.SaveAs "c:\YaddaYadda.xls"

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel crashes with long file names

Hi Jan

Thanks for that.

I'd already thought of that one but hadn't included it in the original post.
It will probably be the simplest solution though so I'll probably go with it
anyway.

Confuscious

"Jan Karel Pieterse" wrote:

Hi Confuscious,

Apart from the obvious of shortening the
directory or file names, does anyone know how to stop this happening?


Delete the file you're overwriting first:

On error resume next 'In case file is not there
Kill "c:\YaddaYadda.xls"
Activeworkbook.SaveAs "c:\YaddaYadda.xls"

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Excel crashes with long file names


"Confuscious" ...
Hi Jan

Thanks for that.

I'd already thought of that one but hadn't included it in the original
post.
It will probably be the simplest solution though so I'll probably go with
it
anyway.

Confuscious

"Jan Karel Pieterse" wrote:

Hi Confuscious,

Apart from the obvious of shortening the
directory or file names, does anyone know how to stop this happening?


Delete the file you're overwriting first:

On error resume next 'In case file is not there
Kill "c:\YaddaYadda.xls"
Activeworkbook.SaveAs "c:\YaddaYadda.xls"

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com




Reply
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 03:45 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"