Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Location: Lund, Sweden.
Posts: 5
Question Second run of macro hangs on .show of application.filedialog object!

Dear All!

I am new to this forum and quite new on programming Excel VBA as well, but here goes...

I am programming a module containing a Sub that employs the application.filedialog object to get the path to a folder from the user.

It works fine the first time I run it after starting Excel, but it hangs when I attempt it the second time. I use the Task Manager to close Excel and get the message that "The system cannot end this program because it is waiting for a response from you".

I think that I understand as much as that the filedialog object belongs to the Excel application as such and I guess it somehow persists between my macro runs. I also assume that somewhere in my macro I am doing something to change its state and cause it to malfunction the second time around.

I could post some code, but thought that a quick fix would be if it was somehow possible to reset or reload the filedialog object from scratch. I have not found such a possibility and to my surprise I have not been able to find any one else describing this issue on this or other forums.

Any help would be greatly appreciated!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Second run of macro hangs on .show of application.filedialog object!

I've always found this much more consistently reliable...

Function GetDirectory$(Optional OpenAt, Optional Msg$)
Dim SH As Object

If Msg = "" Then Msg = "Please choose a folder"
Set SH = CreateObject("Shell.Application").BrowseForFolder( 0, Msg,
&H40 Or &H10, OpenAt)

On Error Resume Next
GetDirectory = SH.Self.Path
On Error GoTo 0
Set SH = Nothing
End Function 'GetDirectory()

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #3   Report Post  
Junior Member
 
Location: Lund, Sweden.
Posts: 5
Thumbs up

Quote:
Originally Posted by GS[_2_] View Post
I've always found this much more consistently reliable...

Function GetDirectory$(Optional OpenAt, Optional Msg$)
Dim SH As Object

If Msg = "" Then Msg = "Please choose a folder"
Set SH = CreateObject("Shell.Application").BrowseForFolder( 0, Msg,
&H40 Or &H10, OpenAt)

On Error Resume Next
GetDirectory = SH.Self.Path
On Error GoTo 0
Set SH = Nothing
End Function 'GetDirectory()

--
Garry
Works like a charm! How do I join your fan-list Garry?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Second run of macro hangs on .show of application.filedialog object!

'GS[_2_ Wrote:
;1616942']I've always found this much more consistently reliable...

Function GetDirectory$(Optional OpenAt, Optional Msg$)
Dim SH As Object

If Msg = "" Then Msg = "Please choose a folder"
Set SH = CreateObject("Shell.Application").BrowseForFolder( 0, Msg,
&H40 Or &H10, OpenAt)

On Error Resume Next
GetDirectory = SH.Self.Path
On Error GoTo 0
Set SH = Nothing
End Function 'GetDirectory()

--
Garry


Works like a charm! How do I join your fan-list Garry?


I don't know anything about a fan-list, but I do appreciate the
feedback!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Application.FileDialog(msoFileDialogFolderPicker) Ayo Excel Discussion (Misc queries) 1 March 12th 08 01:01 PM
Application.FileDialog(msoFileDialogSaveAs) greg Excel Programming 0 February 21st 08 05:58 PM
Application.FileDialog(msoFileDialogSaveAs) [email protected] Excel Programming 0 February 21st 08 02:19 AM
Application.FileDialog(msoFileDialogOpen) H.A. de Wilde[_11_] Excel Programming 1 June 4th 06 09:56 PM
Alternative to Application.FileDialog (please)? Rob Bovey Excel Programming 0 September 9th 04 11:20 AM


All times are GMT +1. The time now is 11:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"