find file but not open it
find file but not open it
find file but not open it
find file but not open it
find file but not open it
find file but not open it find file but not open it find file but not open it find file but not open it find file but not open it find file but not open it find file but not open it find file but not open it
find file but not open it find file but not open it
find file but not open it
Go Back  Xtreme Visual Basic Talk > > > find file but not open it


Reply
 
Thread Tools Display Modes
  #1  
Old 02-20-2017, 05:31 PM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 287
Default find file but not open it


I need my users to search for one specific file, for which (since the file could be anywhere) I have used the CDL 'Open' so they can navigate to it - though I don't actually want them to open the file, I just want its name and path since I need to copy it to a different location as a backup. Is there any way of searching for this file other than using the CDL, since when I find it and click it so it appears in the file name box, I get a message box saying the file exists. Of course it does - I just found it!
All ways of finding a specific file I have seen through search engines assume the user knows what folder the file is in, but I can't make that assumption. Can I use the 'OK' button on the 'open' CDL to run a routine which just gets the file name, and/or bypass the message box?
Reply With Quote
  #2  
Old 02-21-2017, 03:00 AM
Flyguy's Avatar
Flyguyfind file but not open it Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,164
Default

Please show the CDL parameters you used.
Reply With Quote
  #3  
Old 02-21-2017, 09:08 AM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 287
Default

Hi, thanks for replying so quickly.
Code:
With Me.cdlFindobs
.DefaultExt = ".mdb"
.DialogTitle = "Locate starcharts.mdb"
.Filter = "Access Databases|*.mdb"
.ShowOpen
thefile = .FileTitle 'gets name of the file, not the path.
End With
'thefile' has been dimmed as string. I was wondering if there was any way to intercept what happens when the user hits the CDL's OK button? Or is there a better way altogether? Use a file box rather than a CDL?
Reply With Quote
  #4  
Old 02-22-2017, 03:14 AM
Flyguy's Avatar
Flyguyfind file but not open it Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,164
Default

And you get a prompt/messagebox stating the file you selected already exists?

This sample needs a form with a CommandButton (Command1), a Label (Label1) and a CommonDialog control (CommonDialog1)
No prompt/messagebox from the control.
Code:
Option Explicit

Private Sub Command1_Click()
  On Error GoTo CancelError
  With CommonDialog1
    .CancelError = True
    .DialogTitle = "Choose a file"
    .Flags = cdlOFNFileMustExist Or cdlOFNExplorer Or cdlOFNLongNames
    .ShowOpen
    Label1.Caption = .FileTitle
  End With
  Exit Sub

CancelError:
  Label1.Caption = "No file selected"
End Sub

Last edited by Flyguy; 02-22-2017 at 03:20 AM.
Reply With Quote
  #5  
Old 02-22-2017, 05:00 AM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 287
Default

Thanks mate, I'll give that a go - but I think I may be able to do something similar with drive/folder/file boxes. However your solution looks easier since I already have a CDL. Cheers.

Quick edit - in the end I picked the drive/folder/file box combo. That worked!

Last edited by starmanMike; 02-22-2017 at 01:06 PM.
Reply With Quote
Reply

Tags
file, box, cdl, message, specific, search, finding, engines, assume, found, bypass, exists, user, button, run, assumption, and/or, folder, routine, click, path, copy, navigate, location, appears


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
find file but not open it
find file but not open it
find file but not open it find file but not open it
find file but not open it
find file but not open it
find file but not open it find file but not open it find file but not open it find file but not open it find file but not open it find file but not open it find file but not open it
find file but not open it
find file but not open it
 
find file but not open it
find file but not open it
 
-->