Hello everyone,
I have a button on a form that calls a function to populate some textboxes with where criteria that is used in a parameterized query this is then used as the table source for a macro which is calling the transfertext function.
What I want to be able to do is have a saveas dialog box open when they click the button and populate a textbox with the path and filename the user enters. Then I want to use the variable with the stored path as the filename argument in the transfertext function.
So how do I get the saveas dialogue box to open and also, how do I save the path and filename in a variable?
Any Suggestions? Is this possible?
Thanks to everyone for the help.
17 12478
I think this is what you're looking for -
Private Sub cmdYourButton_Click()
-
-
Dim dlgSaveAs As FileDialog
-
Dim strFilePath As String
-
Dim strFileName As String
-
-
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
-
-
dlgSaveAs.Show
-
strFilePath = dlgSaveAs.SelectedItems(1)
-
-
Me.yourTextBox = strFilePath
-
-
strFileName = Right(strFilePath, Len(strFilePath) - InStrRev(strFilePath, "\"))
-
strFilePath = Left(strFilePath, InStrRev(strFilePath, "\"))
-
End Sub
-
Replace youTextBox with the name of your text box and of course code this for your command button's click() event.
I think this is what you're looking for -
Private Sub cmdYourButton_Click()
-
-
Dim dlgSaveAs As FileDialog
-
Dim strFilePath As String
-
Dim strFileName As String
-
-
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
-
-
dlgSaveAs.Show
-
strFilePath = dlgSaveAs.SelectedItems(1)
-
-
Me.yourTextBox = strFilePath
-
-
strFileName = Right(strFilePath, Len(strFilePath) - InStrRev(strFilePath, "\"))
-
strFilePath = Left(strFilePath, InStrRev(strFilePath, "\"))
-
End Sub
-
Replace youTextBox with the name of your text box and of course code this for your command button's click() event.
First of all thanks for the prompt response.
There seems to be a problem with the FileDialog type. Is this a user defined type?
No, it is a member of the Microsoft Office 11.0 Object Library. Check to make sure you have a reference to that by going to tools > references. If it's not checked just find it and check that off.
Tools > References in what application? I am using MS Access 11.6
Tools > References in what application? I am using MS Access 11.6
I found it. It was selected and I still get the same error.
Sorry I should have be more clear. In the Microsft Visual Basic Editor. There should be a menu item Tools from there navigate to references.
It says
Comple Error -
User defined type is not declared.
What version of access are you using?
What version of access are you using?
Microsoft Access (11.6566.6568) SP2
Check the references once more and make sure you haven't mistaken Microsoft Access 11.0 Object Library for Microsoft Office 11.0 Object Library. Both should be checked.
Check the references once more and make sure you haven't mistaken Microsoft Access 11.0 Object Library for Microsoft Office 11.0 Object Library. Both should be checked.
That was the problem. Thanks!!!
strFilePath = dlgSaveAs.SelectedItems(1)
When the user clicks on cancel after the save as dialog box is opened I get an error on this piece of code. Is there a way to avoid this?
Error: "Invalid procedure call or argument"
You can trap this by using the show method. It returns false on cancel. -
Dim dlgSaveAs As FileDialog
-
Dim strPath As String
-
-
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
-
-
If dlgSaveAs.Show = True Then
-
strPath = dlgSaveAs.SelectedItems(1)
-
Else
-
MsgBox "Save was cancelled"
-
End If
-
Hi,I am using Microsoft Access 12.0 Object Library and Microsoft Office 12.0 Access Database Engine Object Library then what should i do because its not running. Both are checked. Please reply. I am waiting.
You can trap this by using the show method. It returns false on cancel. -
Dim dlgSaveAs As FileDialog
-
Dim strPath As String
-
-
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
-
-
If dlgSaveAs.Show = True Then
-
strPath = dlgSaveAs.SelectedItems(1)
-
Else
-
MsgBox "Save was cancelled"
-
End If
-
JKing, I'm still getting a Compile error "User defined type not defined"
I have both Microsoft Access/Excel 11.0 Object library checked in References and I'm using Access 2003. Any idea why?
Do you also have Microsoft Office 11.0 Library checked?
Do you also have Microsoft Office 11.0 Library checked?
Now I do (office 12.0 library) , works fine now. Thanks JKing
Sign in to post your reply or Sign up for a free account.
Similar topics
by: TOM |
last post by:
I want to saveas silently ! it will not prompt to user for saveas please tell me how can I do this silently.
please do replay !
OLEObject IE
IE = CREATE OLEObject
|
by: kevin |
last post by:
Hi,
Any help with this would be really appreciated!
I'm trying to download a file from a remote server. The access
permissions is okay but the problem I'm facing is that the file is
getting...
|
by: Ger |
last post by:
My dialogue form (sometimes partly, sometimes as a whole) remains visible
during a fairly long processing job.
The dialogue asks the user to enter some data for the job to follow, and
after OK,...
|
by: sasan3 |
last post by:
Please read below for my collective response to recent posts on this
topic.
First a repeat of my suggestion:
"Anytime you feel you are in a position to answer a question, but
don't
feel like...
|
by: Reddy |
last post by:
System.Web.UI.HtmlControls.HtmlInputFile.SaveAs(FileName) is not overwriting
the file. It used to work fine on IIS5.1 Recently we migrated to IIS6.0.
Since then it's not working. If it's new file...
|
by: michaellm |
last post by:
Hi ALL,
In VB.Net,
I create an Excel as followed:
Dim excelapp As New Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
' Get a new workbook.
oWB =...
|
by: UltimateNickFury |
last post by:
Hello,
I am trying to display the "Printer Settings" dialogue in vb.net. I have
found the code for performing this in VB6 but am wondering how this is done
in vb.net. Thanks.
|
by: Lance Hoffmeyer |
last post by:
Hey all,
As always, thanks in advance!
I am trying to save a ppt presentation but am having problems regarding spaces and am wondering
if I am doing something wrong or whether this is a bug?...
|
by: Donn Ingle |
last post by:
Hi,
Okay, so I am in the mood to try this: Inform the user about what modules
the app requires in a graphical dialogue that can vary depending on what
the system already has installed. (It will...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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,...
|
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...
| |