Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Return value for Cancel?

I've got some operational code for my project, and everything works as
long as there are no deviations from the norm. But, we all know
deviations are going to happen. So, I want to be able to create an
If-Then to check if the user does not select a workbook from the
selection screen. Right now the code is:

UF = Application.GetOpenFilename(FileFilter:="XML Files (*.xml)",
Title:="This Weeks Projections for Marc")
Workbooks.Open Filename:=UF

Set wbUF = Workbooks.Open(Filename:=UF)
UFFN = wbUF.Name

Sheets("Marc").Select
Sheets("Marc").Copy After:=Workbooks("Projection
Summary.xls").Sheets("Summary")
Windows(UFFN).Activate
ActiveWindow.Close


Obviously if the user clicks Cancel, I'm going to get error messages, so
what value does the cancel button return that I can use in an If-Then
statement?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Return value for Cancel?

UF = Application.GetOpenFilename(FileFilter:="XML Files (*.xml)", _
Title:="This Weeks Projections for Marc")
If UF < "" Then
Workbooks.Open Filename:=UF

Set wbUF = Workbooks.Open(Filename:=UF)
UFFN = wbUF.Name

Sheets("Marc").Select
Sheets("Marc").Copy After:=Workbooks("Projection
Summary.xls").Sheets("Summary")
Windows(UFFN).Activate
ActiveWindow.Close
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jason Hancock" wrote in message
...
I've got some operational code for my project, and everything works as
long as there are no deviations from the norm. But, we all know
deviations are going to happen. So, I want to be able to create an
If-Then to check if the user does not select a workbook from the
selection screen. Right now the code is:

UF = Application.GetOpenFilename(FileFilter:="XML Files (*.xml)",
Title:="This Weeks Projections for Marc")
Workbooks.Open Filename:=UF

Set wbUF = Workbooks.Open(Filename:=UF)
UFFN = wbUF.Name

Sheets("Marc").Select
Sheets("Marc").Copy After:=Workbooks("Projection
Summary.xls").Sheets("Summary")
Windows(UFFN).Activate
ActiveWindow.Close


Obviously if the user clicks Cancel, I'm going to get error messages, so
what value does the cancel button return that I can use in an If-Then
statement?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Return value for Cancel?

Thanks!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Workbook_BeforeClose(Cancel As Boolean) - Cancel won't work gpmichal Setting up and Configuration of Excel 1 May 12th 09 02:33 AM
msgbox cancel? sycsummit Excel Discussion (Misc queries) 2 February 11th 09 04:37 PM
cancel save lawson Excel Discussion (Misc queries) 1 October 11th 07 11:00 PM
Read Only - How to Cancel? Glenn Excel Discussion (Misc queries) 1 August 26th 05 06:23 PM
How to Cancel a Save? Rodg2000 Excel Programming 1 January 9th 04 10:47 AM


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

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

About Us

"It's about Microsoft Excel"