473,396 Members | 2,052 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,396 software developers and data experts.

SaveAs Dialogue box

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.
Jul 18 '07 #1
17 12478
JKing
1,206 Expert 1GB
I think this is what you're looking for

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdYourButton_Click()
  2.  
  3. Dim dlgSaveAs As FileDialog
  4. Dim strFilePath As String
  5. Dim strFileName As String
  6.  
  7. Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
  8.  
  9. dlgSaveAs.Show
  10. strFilePath = dlgSaveAs.SelectedItems(1)
  11.  
  12. Me.yourTextBox = strFilePath
  13.  
  14. strFileName = Right(strFilePath, Len(strFilePath) - InStrRev(strFilePath, "\"))
  15. strFilePath = Left(strFilePath, InStrRev(strFilePath, "\"))
  16. End Sub
  17.  
Replace youTextBox with the name of your text box and of course code this for your command button's click() event.
Jul 18 '07 #2
I think this is what you're looking for

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdYourButton_Click()
  2.  
  3. Dim dlgSaveAs As FileDialog
  4. Dim strFilePath As String
  5. Dim strFileName As String
  6.  
  7. Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
  8.  
  9. dlgSaveAs.Show
  10. strFilePath = dlgSaveAs.SelectedItems(1)
  11.  
  12. Me.yourTextBox = strFilePath
  13.  
  14. strFileName = Right(strFilePath, Len(strFilePath) - InStrRev(strFilePath, "\"))
  15. strFilePath = Left(strFilePath, InStrRev(strFilePath, "\"))
  16. End Sub
  17.  
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?
Jul 18 '07 #3
JKing
1,206 Expert 1GB
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.
Jul 18 '07 #4
Tools > References in what application? I am using MS Access 11.6
Jul 18 '07 #5
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.
Jul 18 '07 #6
JKing
1,206 Expert 1GB
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.
Jul 18 '07 #7
It says

Comple Error -

User defined type is not declared.
Jul 18 '07 #8
JKing
1,206 Expert 1GB
What version of access are you using?
Jul 18 '07 #9
What version of access are you using?
Microsoft Access (11.6566.6568) SP2
Jul 18 '07 #10
JKing
1,206 Expert 1GB
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.
Jul 18 '07 #11
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!!!
Jul 18 '07 #12
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"
Jul 18 '07 #13
JKing
1,206 Expert 1GB
You can trap this by using the show method. It returns false on cancel.

Expand|Select|Wrap|Line Numbers
  1. Dim dlgSaveAs As FileDialog
  2. Dim strPath As String
  3.  
  4. Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
  5.  
  6. If dlgSaveAs.Show = True Then
  7.     strPath = dlgSaveAs.SelectedItems(1)
  8. Else
  9.     MsgBox "Save was cancelled"
  10. End If
  11.  
Jul 18 '07 #14
newwin
3
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.
Sep 4 '07 #15
fd1
38
You can trap this by using the show method. It returns false on cancel.

Expand|Select|Wrap|Line Numbers
  1. Dim dlgSaveAs As FileDialog
  2. Dim strPath As String
  3.  
  4. Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
  5.  
  6. If dlgSaveAs.Show = True Then
  7.     strPath = dlgSaveAs.SelectedItems(1)
  8. Else
  9.     MsgBox "Save was cancelled"
  10. End If
  11.  
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?
Sep 15 '07 #16
JKing
1,206 Expert 1GB
Do you also have Microsoft Office 11.0 Library checked?
Sep 15 '07 #17
fd1
38
Do you also have Microsoft Office 11.0 Library checked?
Now I do (office 12.0 library) , works fine now. Thanks JKing
Sep 16 '07 #18

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

Similar topics

0
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
5
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...
12
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,...
44
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...
5
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...
2
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 =...
3
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.
2
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?...
12
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...
0
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
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...
1
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...
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
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...
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
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.