Solved

Need Help with FileDialog Property in MS Acess VBA

Posted on 2004-09-24
6
546 Views
Last Modified: 2010-07-27
Hi All,

  I'm trying to use the File Dialog property to get input from a user to get the name and location to create a exported spreadsheet.

  I can export the spreadsheet fine.  Here is the problem.

  Here is the code:

Dim dlgSaveAs As FileDialog

    Set dlgSaveAs = Application.FileDialog( FileDialogType:=msoFileDialogSaveAs)

    dlgSaveAs.Show

Here is the error - the Dim statement is where the error is happening

Compile:  Error

User-Defined type not defined

Can anybody help?

Thanks in Advance
0
Comment
Question by:jcosta_sr
  • 2
6 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12146084
Just change it to:
Dim dlgSaveAs As Object

That should do it.
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 12146412
0
 

Author Comment

by:jcosta_sr
ID: 12146774
when I subsitute object for FileDialog the first line passes but then the second line

Set dlgSaveAs = Application.FileDialog( FileDialogType:=msoFileDialogSaveAs)

fails

Named argument not found.  (FileDialogType is highlighted)
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 500 total points
ID: 12146813
Remove the FileDialogType:= part, so you have:
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)

(the argument is DialogType, I believe not FileDialogType). You may need to add a reference to the Microsoft Office <your version) Object Library for this to work. Otherwise, this should also work:

Set dlgSaveAs = Application.FileDialog(2)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now