Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default using a filedialog box from a dll

I compiled a working dll with office XP developer (code below). It does the
following:
1) loads a folder picker dialog box.
2) I choose a folder and save it to a variable
3) when "OPEN" is clicked msgbox is generated
I am call this function via a custom menu item
Problem/Issue occurs when the if statement is being executed, Excel
hangs/stops responding. I think it has to do with the dialog being/not being
modal but there does not seem to be any way to change that. Also when the
diabox is ls loaded it does not get the focus. What is up with that?
Thanks in advance

Private Sub message()
MsgBox "Can you read this"
Dim DefaultDir As String
Set folder = Application.FileDialog(msoFileDialogFolderPicker)
If folder.Show < 0 Then
DefaultDir = folder.SelectedItems.Item(1) & "\"
MsgBox "Default Dir is " & DefaultDir
ElseIf folder.Show = 0 Then
MsgBox "cancel button selected."
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default using a filedialog box from a dll

I can't answer your questions, but I know you don't want to use folder.show
twice:

Private Sub message()
MsgBox "Can you read this"
Dim DefaultDir As String
Set folder = Application.FileDialog(msoFileDialogFolderPicker)
If folder.Show < 0 Then
DefaultDir = folder.SelectedItems.Item(1) & "\"
MsgBox "Default Dir is " & DefaultDir
Else
MsgBox "cancel button selected."
End If
End Sub

If it wasn't "Not zero", then it must be zero, so no need to show the dialog
a second time to ask the user again.

--
Regards,
Tom Ogilvy


"Paul" wrote:

I compiled a working dll with office XP developer (code below). It does the
following:
1) loads a folder picker dialog box.
2) I choose a folder and save it to a variable
3) when "OPEN" is clicked msgbox is generated
I am call this function via a custom menu item
Problem/Issue occurs when the if statement is being executed, Excel
hangs/stops responding. I think it has to do with the dialog being/not being
modal but there does not seem to be any way to change that. Also when the
diabox is ls loaded it does not get the focus. What is up with that?
Thanks in advance

Private Sub message()
MsgBox "Can you read this"
Dim DefaultDir As String
Set folder = Application.FileDialog(msoFileDialogFolderPicker)
If folder.Show < 0 Then
DefaultDir = folder.SelectedItems.Item(1) & "\"
MsgBox "Default Dir is " & DefaultDir
ElseIf folder.Show = 0 Then
MsgBox "cancel button selected."
End If
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default using a filedialog box from a dll

Thanks tom, a slight typo. after further review testing and pulling hair. I
have found out a think or two that I would like to add.
1) when I select my folder and select the "OPEN" button the msgbox opens a
new excel window. I have to ALT+TAB to find it and select the "OK" button on
the msgbox but the second generated excel window is still there. I have been
reading in the help and it says that when the filedialog box starts it waits
for user input and after the user selects "OPEN" or "CANCEL" VBA continues on
its mary way with the next line of code.
Hope this help
Thanks again for your help.

"Tom Ogilvy" wrote:

I can't answer your questions, but I know you don't want to use folder.show
twice:

Private Sub message()
MsgBox "Can you read this"
Dim DefaultDir As String
Set folder = Application.FileDialog(msoFileDialogFolderPicker)
If folder.Show < 0 Then
DefaultDir = folder.SelectedItems.Item(1) & "\"
MsgBox "Default Dir is " & DefaultDir
Else
MsgBox "cancel button selected."
End If
End Sub

If it wasn't "Not zero", then it must be zero, so no need to show the dialog
a second time to ask the user again.

--
Regards,
Tom Ogilvy


"Paul" wrote:

I compiled a working dll with office XP developer (code below). It does the
following:
1) loads a folder picker dialog box.
2) I choose a folder and save it to a variable
3) when "OPEN" is clicked msgbox is generated
I am call this function via a custom menu item
Problem/Issue occurs when the if statement is being executed, Excel
hangs/stops responding. I think it has to do with the dialog being/not being
modal but there does not seem to be any way to change that. Also when the
diabox is ls loaded it does not get the focus. What is up with that?
Thanks in advance

Private Sub message()
MsgBox "Can you read this"
Dim DefaultDir As String
Set folder = Application.FileDialog(msoFileDialogFolderPicker)
If folder.Show < 0 Then
DefaultDir = folder.SelectedItems.Item(1) & "\"
MsgBox "Default Dir is " & DefaultDir
ElseIf folder.Show = 0 Then
MsgBox "cancel button selected."
End If
End Sub

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
FileDialog AMDRIT Excel Programming 1 October 21st 05 10:17 PM
filedialog Norm Excel Worksheet Functions 0 July 29th 05 10:17 PM
FileDialog - Not available in 2k? RWN Excel Programming 3 March 12th 05 05:25 AM
FileDialog Help Maynard Excel Programming 0 August 4th 04 01:43 PM
FileDialog Jag Man Excel Programming 3 February 2nd 04 04:50 AM


All times are GMT +1. The time now is 10:56 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"