Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default How do I determine if it is a new file or an existing file?

How can I tell (via VBA code) if the workbook is a new workbook from a
template or an existing workbook?

If it is a new workbook, I want to SaveAs and give it a name. If it is an
existing file, I just want to save it.

I already understand the SaveAs and Save methods. I just don't know how to
check whether it is new or existing.

Thanks for any help anyone can provide,

Conan Kelly


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How do I determine if it is a new file or an existing file?

Hi Conan

A workbook that is not saved one time have no path so you can test it like this.

Sub test()
If ActiveWorkbook.Path = "" Then
MsgBox "New workbook"
Else
MsgBox "Old workbook"
End If
End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl


"Conan Kelly" <CTBarbarin at msn dot com wrote in message ...
How can I tell (via VBA code) if the workbook is a new workbook from a template or an existing workbook?

If it is a new workbook, I want to SaveAs and give it a name. If it is an existing file, I just want to save it.

I already understand the SaveAs and Save methods. I just don't know how to check whether it is new or existing.

Thanks for any help anyone can provide,

Conan Kelly



  #3   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default How do I determine if it is a new file or an existing file?

try this

sub checknew()
if workbooks("namehere").path = "" then
'workbook is new
else
'workbook is not new
end if
end sub
--
When you lose your mind, you free your life.


"Conan Kelly" wrote:

How can I tell (via VBA code) if the workbook is a new workbook from a
template or an existing workbook?

If it is a new workbook, I want to SaveAs and give it a name. If it is an
existing file, I just want to save it.

I already understand the SaveAs and Save methods. I just don't know how to
check whether it is new or existing.

Thanks for any help anyone can provide,

Conan Kelly



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
import data from txt file to an existing excel file shaji Excel Discussion (Misc queries) 1 September 12th 09 04:15 PM
Determine Excel file version with no file extension. tjlumpkin Excel Discussion (Misc queries) 2 July 23rd 09 06:59 AM
User replaces existing file with blank during file open sjs Excel Discussion (Misc queries) 3 August 18th 08 06:16 PM
Importing text file, only option to edit existing file smokey99 Excel Discussion (Misc queries) 8 April 26th 06 09:08 PM
can i save an existing .xls file as a .csv file using command line craigkan Excel Discussion (Misc queries) 2 February 18th 05 02:01 PM


All times are GMT +1. The time now is 08:51 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"