FileDialog comes up behind form!

tkpstock

Cubicle Warrior
Local time
Today, 08:27
Joined
Feb 25, 2005
Messages
206
I am attempting to use FileDialog, but when I show it, it comes up behind my form! How can I correct this?

Thanks in advance!

Here's my code:

Dim dlgSaveAs As FileDialog
Set dlgSaveAs = Application.FileDialog(DialogType:=msoFileDialogSaveAs)
dlgSaveAs.Show
 
Last edited:
That works for me... I'll try and find a way to open behind the form. Do a compact and repair just in case.

try putting dlgSaveAs.Execute after your code, though.


additionally: in your form's load() event, turn off the always on top property.
SetTopMostWindow FormName.hwnd, False
see if that helps at all

-modest
 
Last edited:
SetTopMostWindow?

I tried using SetTopMostWindow - it said "Sub or Function Not Defined". Is that an ealier version of access? (I've now added my version to my signature, which I should've done before).

Doesn't the 'dlgSaveAs.Execute' command carry out the save operation? If so, I really only want to return the user's response as a string.

Thanks!
 
Sorry, it's just something I used to use.

Check: http://support.microsoft.com/kb/q184297/

just use:
SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS


...just for shits and giggles, could you take a screenprint of your app... I just want to see :)
 
Last edited:
tkpstock said:
I tried using SetTopMostWindow - it said "Sub or Function Not Defined". Is that an ealier version of access? (I've now added my version to my signature, which I should've done before).

Doesn't the 'dlgSaveAs.Execute' command carry out the save operation? If so, I really only want to return the user's response as a string.

Thanks!
SetTopMostWindow is an api function and therefore you need to import it first in order to use it. I have created a a code module which you could use here
 
dt01pqt said:
SetTopMostWindow is an api function and therefore you need to import it first in order to use it. I have created a a code module which you could use here

My link above goes directly to Microsoft's site.. and gives you the code for the module; however the "SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS" is all you need. Just disregard the SetTopMostWindow and use this line in your code.

You do need to put this in a module to use it though:

Code:
Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2

Declare Function SetWindowPos Lib "user32" _
      (ByVal hwnd As Long, _
      ByVal hWndInsertAfter As Long, _
      ByVal x As Long, _
      ByVal y As Long, _
      ByVal cx As Long, _
      ByVal cy As Long, _
      ByVal wFlags As Long) As Long
 
Last edited:
Crashed... :)

Well, now that I inserted the function and called it, the database just locks up when I go to the method that calls the API function. As soon as I force-kill the application, the SaveAs dialog box appears! (A little too late, in my estimation!)

I'll figure out another way to do it without the API calls. I am not familiar enough with API calls to use them effectively.

I can't include a screenshot because I don't have FTP access here at work to be able to publish the pic online anywhere.

Thanks for your help!
 
1) open Access... press Alt + PrintScreen
2) Goto Paint (or another graphic editor) and paste it
3) Save as a jpg (or other file format)
4) Zip it
5) Add the zip as an attachment to a post

--- no need for ftp ---

Your database shouldn't be locking up.

First: Make sure you posted the function declaration in a module.
Second: Paste this into your form_load() event
Code:
SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS
 
Never scrolled far enough!! :) LOL

I never scrolled down far enough to see the attachment section! That's why I didn't think I could do it. I've attached a screenshot.

BTW, I've got the API working ok, but I realized that I am not using the FileDialog object - msoFileDialogSaveAs is not supported for MS Access, so I am attempting to use the Excel one:

Excel.Application.GetSaveAsFilename("", "Excel files (*.xls),*.xls", , "Choose file name and location!")

This is what is coming up behind the Access application. The chart you see on the screenshot is an embedded excel spreadsheet (linked to a temporary file I create on a network share). After the user closes the form, the file automatically is killed. The Parameters / Operators / Data allows the user to define their own query criteria. The "Refresh Data" button refreshes the chart using the criteria. The Export to Excel button is the one that currently only half works.

I want the user to be able to save the excel file on their local machine without losing my object references to the embedded spreadsheet.

Sorry, I misstated my original post.

Thanks!
 

Attachments

  • ScreenShot.jpg
    ScreenShot.jpg
    50.5 KB · Views: 349
Last edited:
AGGGh... First... I wanted to see your whole Access application. Second, I was hoping you would zip it because seeing a compressed blurry picture is not appealing, or useful. Third, who says msoFileDialogSaveAs isn't supported for Access?... it works for me.

Finally, could you please restate your problem again. Let's try this from a clean slate.
 
Last edited:
msoFileDialogSaveAs and Excel.GetSaveAsFilename

Here is the article about msoFileDialogSaveAs: Microsoft Q282335

I can't post the entire application - it is 22MB (compressed) and contains proprietary company information (I'm in R&D).

The crux of the matter is that when I use Excel's GetSaveAsFilename, it throws up the dialog box behind the form I'm calling it from. It may be that the API method I'm using (SetWindowPos) is only working within the Access Application since the GetSaveAsFilename method is in the Excel application (which is currently hidden at the time of the calling). Does that make sense?

I would use the Windows API file dialogs, but I am completely unfamiliar with them.

Thanks!
 
Well I wouldn't have you do anything that would get you in trouble, but if you zip a database, you'll find that WinZip normally compresses it around 80-90%

All we need to look at is the code anyhow, so just delete all the records of the table, but don't do it if it's a hassle, or if you feel queer about it. Anyhow, I don't normally use the filedialog... but i did at home (with msoFileDialogSaveAs) on my MSO2k3, which may be the reason it worked?

I dont know... I think we're missing something simple here and I'm going to be upset when someone posts it - just because this thread has lasted too long.

I think you should post a little more code though. And where/when is this being triggered?

-modest
 
Finally...

After cut/pasting the API code and trying it out, it appears to work well. I will have to figure out how to customize it for my purposes (such as changing the dialog and button captions), but it appears to work great!

Posting a copy of my DB here would certainly get me in trouble. I would have to delete the contents of all 40 tables and go through my code to see what proprietary info is in there... not gonna happen. Some of the fieldnames are also proprietary - I know it sounds hokie, but 'tis true.

They probably did correct the msoFileDialogSaveAs problem with MSO 2003 because the article states that it's only a problem with 2002.

Thanks for all of your help! I think you can finally lay this thread to bed! :)
 
RoyVidar said:
There are some really handy wrappers for some of those available, for instance
http://www.mvps.org/access/api/api0001.htm


I know this isn't funny...

....but the funny thing is last week I was customizing this code in one of my db's to do an auto search/save and I didn't think to post it. =)

:::glad you got your stuff together tkp
-modest
 

Users who are viewing this thread

Back
Top Bottom