Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Capturing 'Cancel' on Applicaiton.Dialogs(xlDialogOpen).Show FilePathAndName

Hello there,

I have read many instances of how to use the Open dialog on many
different sites and haven't found a way to capture the 'cancel' button
when there is a file already selected.

Here is the code that I am using:
FilePathAndName= Range("BY35").Value
Application.Dialogs(xlDialogOpen).Show FilePathAndName

I know that there is another way to get the open dialog box using the
following code:
FileName = Application.GetOpenFilename

Even this has problems handling the 'cancel' button when a file was
selected.

Can anyone help?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Capturing 'Cancel' on Applicaiton.Dialogs(xlDialogOpen).Show FileP

executing this line:
Result=Application.Dialogs(xlDialogOpen).Show

returns True if a file has been opened, and FALSE if the user presses Cancel.
--
p45cal


"theSquirrel" wrote:

Hello there,

I have read many instances of how to use the Open dialog on many
different sites and haven't found a way to capture the 'cancel' button
when there is a file already selected.

Here is the code that I am using:
FilePathAndName= Range("BY35").Value
Application.Dialogs(xlDialogOpen).Show FilePathAndName

I know that there is another way to get the open dialog box using the
following code:
FileName = Application.GetOpenFilename

Even this has problems handling the 'cancel' button when a file was
selected.

Can anyone help?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Capturing 'Cancel' on Applicaiton.Dialogs(xlDialogOpen).Show FileP


Sub test()

Filename = Application.GetOpenFilename
If Filename = False Then
MsgBox "User Cancelled!"
End If

'or
If Application.Dialogs(xlDialogOpen).Show("Z:\TEMP\*. xls") = False Then
MsgBox "User Cancelled!"
End If

End Sub



--
Hope that helps.

Vergel Adriano


"theSquirrel" wrote:

Hello there,

I have read many instances of how to use the Open dialog on many
different sites and haven't found a way to capture the 'cancel' button
when there is a file already selected.

Here is the code that I am using:
FilePathAndName= Range("BY35").Value
Application.Dialogs(xlDialogOpen).Show FilePathAndName

I know that there is another way to get the open dialog box using the
following code:
FileName = Application.GetOpenFilename

Even this has problems handling the 'cancel' button when a file was
selected.

Can anyone help?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Capturing 'Cancel' on Applicaiton.Dialogs(xlDialogOpen).Show FilePathAndName

This is something like what I have used in the past and have never had
any problems, whether a file is selected or not.
s = Application.GetOpenFilename
If s = False Or s = "" Then Exit Sub
MsgBox s

theSquirrel wrote:
Hello there,

I have read many instances of how to use the Open dialog on many
different sites and haven't found a way to capture the 'cancel' button
when there is a file already selected.

Here is the code that I am using:
FilePathAndName= Range("BY35").Value
Application.Dialogs(xlDialogOpen).Show FilePathAndName

I know that there is another way to get the open dialog box using the
following code:
FileName = Application.GetOpenFilename

Even this has problems handling the 'cancel' button when a file was
selected.

Can anyone help?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Capturing 'Cancel' on Applicaiton.Dialogs(xlDialogOpen).Show FileP

On Sep 6, 10:36 am, Vergel Adriano
wrote:
Sub test()

Filename = Application.GetOpenFilename
If Filename = False Then
MsgBox "User Cancelled!"
End If

'or
If Application.Dialogs(xlDialogOpen).Show("Z:\TEMP\*. xls") = False Then
MsgBox "User Cancelled!"
End If

End Sub

--
Hope that helps.

Vergel Adriano

"theSquirrel" wrote:
Hello there,


I have read many instances of how to use the Open dialog on many
different sites and haven't found a way to capture the 'cancel' button
when there is a file already selected.


Here is the code that I am using:
FilePathAndName= Range("BY35").Value
Application.Dialogs(xlDialogOpen).Show FilePathAndName


I know that there is another way to get the open dialog box using the
following code:
FileName = Application.GetOpenFilename


Even this has problems handling the 'cancel' button when a file was
selected.


Can anyone help?


Vergel...

This is brilliant! it is exactly what I was looking for!!

If Application.Dialogs(xlDialogOpen).Show("Z:\TEMP\*. xls") = False
Then
MsgBox "User Cancelled!"
End If

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
Application.Dialogs(xlDialogPrint).Show - prints too soon Almagg via OfficeKB.com Excel Discussion (Misc queries) 3 April 27th 07 08:17 PM
returning values application.dialogs(...).show Pringles. Excel Programming 2 July 31st 06 04:11 PM
Application.Dialogs(xlDialogSendMail).Show James T Excel Programming 1 July 18th 06 03:34 AM
Capturing Cancel button on save file dialogue Tanveer_asim Excel Programming 1 August 24th 05 12:56 PM
xlDialogOpen.Show or Activeworkbook.Path? Mike Echo Excel Worksheet Functions 2 January 29th 05 09:51 AM


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