Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro to export files but not replace an exsisting file name

Hi all,
I have a macro that export an excel sheet to a folder
daily. Since the name is always the same. Whenever the
xls is exported it will prompt the user with this inform:
THE FILE BOOK1.XLS ALREADY EXISTS. DO YOU WANT TO REPLACE.
is there a code that i could add to my save filename
statement that will just replace this file?

ALSO, I have added a statement that will export this same
file to another folder. However, i do not want it to
replace this file, but something beside the file name
making it unique from the existing file. Or create a
generic name and auto count these files.
Thanks and i will greatly appreciate any help

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default macro to export files but not replace an exsisting file name

Jessica

Application.DisplayAlerts=False
' your code
Application.DisplayAlerts=True

Regards

Trevor


"jessica" wrote in message
...
Hi all,
I have a macro that export an excel sheet to a folder
daily. Since the name is always the same. Whenever the
xls is exported it will prompt the user with this inform:
THE FILE BOOK1.XLS ALREADY EXISTS. DO YOU WANT TO REPLACE.
is there a code that i could add to my save filename
statement that will just replace this file?

ALSO, I have added a statement that will export this same
file to another folder. However, i do not want it to
replace this file, but something beside the file name
making it unique from the existing file. Or create a
generic name and auto count these files.
Thanks and i will greatly appreciate any help



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default macro to export files but not replace an exsisting file name

Jessica,

Sub testit()
Const cFilename = "C:\T\book1.xls"
Dim blnTemp As Boolean

blnTemp = Application.DisplayAlerts
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs cFilename
Application.DisplayAlerts = blnTemp
End Sub


Here's one method to make a filename unique:

Sub testit()
Dim strFilename As String, strTemp As String, i As Long

strFilename = "C:\T\Book1.xls"

strTemp = strFilename: i = 2
Do Until Dir(strTemp) = ""
strTemp = strFilename & " (" & i & ")"
i = i + 1
Loop
strFilename = strTemp

MsgBox strFilename
End Sub




"jessica" wrote in message
...
Hi all,
I have a macro that export an excel sheet to a folder
daily. Since the name is always the same. Whenever the
xls is exported it will prompt the user with this inform:
THE FILE BOOK1.XLS ALREADY EXISTS. DO YOU WANT TO REPLACE.
is there a code that i could add to my save filename
statement that will just replace this file?

ALSO, I have added a statement that will export this same
file to another folder. However, i do not want it to
replace this file, but something beside the file name
making it unique from the existing file. Or create a
generic name and auto count these files.
Thanks and i will greatly appreciate any help



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
add sheets to exsisting file eagle1247 Excel Discussion (Misc queries) 1 November 19th 08 04:36 PM
Macro Involving Find & Replace In Two Different Files K8_Dog[_2_] Excel Discussion (Misc queries) 4 May 2nd 08 07:44 PM
cannot open exsisting file Mr. Rip Excel Discussion (Misc queries) 1 November 24th 06 01:04 AM
export gif file files k2sarah Charts and Charting in Excel 1 December 5th 05 04:43 PM
A macro to export a sheet as UTF8 encoded Unicode file Dario de Judicibus Excel Programming 5 November 21st 03 07:11 AM


All times are GMT +1. The time now is 06:16 PM.

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"