473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Using SaveAs type FileDialog to enter a new file name?

jamjar
50
I am trying to use the SaveAs type FileDialog to allow the user to enter a file name. It's only letting me choose exisiting files. Is there any way to use the FileDialog to allow the user to select a folder and type in a file name, returning the full path as a string?
This is what I've tried (MS Access 2002, MS Office 10.0 Object Library):
Expand|Select|Wrap|Line Numbers
  1. Function UserSelectedSaveAs(sFilter As String, sFiltName As String, Optional sMsgTitle As String, Optional sInitFile As String) As String
  2.  Dim fd As FileDialog
  3.     Set fd = Application.FileDialog(msoFileDialogFilePicker)
  4.     fd.Title = sMsgTitle
  5.     fd.InitialFileName = sInitFile
  6.     fd.Filters.Clear
  7.     fd.Filters.Add sFiltName, sFilter, 1
  8.     fd.Show
  9.     If fd.Show = -1 Then
  10.         UserSelectedSaveAs = fd.SelectedItems(1)
  11.      Else
  12.         'user cancelled
  13.         MsgBox "Cancelled file save."
  14.         Exit Function
  15.     End If
  16.  
  17.     Set fd = Nothing
  18. End Function
  19.  
James
Sep 27 '07 #1
2 8184
ADezii
8,834 Expert 8TB
I am trying to use the SaveAs type FileDialog to allow the user to enter a file name. It's only letting me choose exisiting files. Is there any way to use the FileDialog to allow the user to select a folder and type in a file name, returning the full path as a string?
This is what I've tried (MS Access 2002, MS Office 10.0 Object Library):
Expand|Select|Wrap|Line Numbers
  1. Function UserSelectedSaveAs(sFilter As String, sFiltName As String, Optional sMsgTitle As String, Optional sInitFile As String) As String
  2.  Dim fd As FileDialog
  3.     Set fd = Application.FileDialog(msoFileDialogFilePicker)
  4.     fd.Title = sMsgTitle
  5.     fd.InitialFileName = sInitFile
  6.     fd.Filters.Clear
  7.     fd.Filters.Add sFiltName, sFilter, 1
  8.     fd.Show
  9.     If fd.Show = -1 Then
  10.         UserSelectedSaveAs = fd.SelectedItems(1)
  11.      Else
  12.         'user cancelled
  13.         MsgBox "Cancelled file save."
  14.         Exit Function
  15.     End If
  16.  
  17.     Set fd = Nothing
  18. End Function
  19.  
James
Is there any way to use the FileDialog to allow the user to select a folder and type in a file name, returning the full path as a string?

Unfortunately, No!

The msoFileDialogOpen and msoFileDialogSaveAs constants, which refer to the FileDialog Types, are not supported in Microsoft Access.
Sep 27 '07 #2
jamjar
50
Thanks for the confirmation ADezii.

Based on that I did some more searching and found some code at http://www.mvps.org/access/api/api0001.htm (a custom file open/save dialog that will accepts user typed input and returns a file path string) which seems to solve the problem.

cheers-

James
Sep 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: John Clark | last post by:
Hi, I am using webbrowser control to automate a site. this site contains form with tage <INPUT TYPE=FILE ...> I know the control is not writeable. So, only thing that I could do was: ...
2
by: | last post by:
I have code to download a file from a webserver to a local machine through the browser using code dim file as System.IO.FileInfo = new System.IO.FileInfo("c:\_6_test.txt") Response.Clear();...
18
by: walterbyrd | last post by:
I am trying to develop an app where: the same file, in the same place, will be uploaded, and then processed. Everything I can find about uploading a file, uses a form that requires the user to...
10
by: Paul | last post by:
Hi I am using the HtmlInputFile control to upload a file from a client to a server. I have a browse to find the file on the server but need to create the path dynamically as to were it will go...
3
by: lumpybanana247 | last post by:
what do i do with "FileName" to beable to pick the name of the file in doss and automatically add ".txt" to the end. (right now, i have to type in the name and ".txt" at the end) #include...
3
by: lumpybanana247 | last post by:
Right now, the output of my file automatically ends in ".txt" (which i want it to) But, i also want the name to start with "C:/Documents and Settings/All Users/Desktop/" How can I add that so...
10
by: Academia | last post by:
I'd like to check a string to see that it is a valid file name. Is there a Like pattern or RegEx that can do that. 1) Just the file name with maybe an extension 2)A full path An help...
1
by: mcfly1204 | last post by:
I am using the XslCompiledTransform class to convert .xml files into .html files. I would like to be able to use a string as part of the file name. For example: ...
7
by: xraive | last post by:
Currently I only get the file path. Is there way to retrieve the file name or do I have to just use the split function. Dim fDialog As Office.FileDialog Dim varFile As Variant ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.