-
FlexPro
- Zoom sur FlexPro
- Fonctionnalités & Options
- Domaines d’application
- Tous les avantages
- Nouveau dans FlexPro 2021
- Testez FlexPro gratuitement
- FlexPro View OEM Freeware
- Conseils d’achat
- Login
- Langue
- +49 6894 929600
- infoweisang.com
- Google Maps
- Produits
- News
- Support
- Société
- Emplois
- Contact
- Login
- Langue
- +49 6894 929600
- infoweisang.com
- Google Maps
Common dialog control
Accueil > Community > Automation and VBA > Common dialog control
- This topic has 10 replies, 3 voices, and was last updated 18 years, 10 months ago by Nicolas Beaupré.
-
AuthorPosts
-
January 18, 2006 at 2:23 am #12422Nicolas BeaupréMember
Hi,
I’ve already seen in VB a control in the toolbox that allow me to select a path and a file by browsing in my computer with an automatic dialog window such as the one in attachment. The dialog should return a string containing the path of the file.
Usually this component can be added to the toolbox by right-clicking on it a choose “additionnal controls”. I know the control I’m looking for is a “Common Dialog Control”. The problem is : when I clik to add ths control to my form, I got this message : the control cannot be created because it is not properly licensed. I’ve asked for it on different forum and the problem seem to come from flexpro.Microsoft have a patch to solve this problem, but it need to have VB6.0 installed, not a VBA application.
http://support.microsoft.com/defaul…kb;EN-US;194751
Is there another way I can get my dialog window ?
ThanksJanuary 18, 2006 at 2:23 am #8103Nicolas BeaupréMemberHi,
I’ve already seen in VB a control in the toolbox that allow me to select a path and a file by browsing in my computer with an automatic dialog window such as the one in attachment. The dialog should return a string containing the path of the file.
Usually this component can be added to the toolbox by right-clicking on it a choose “additionnal controls”. I know the control I’m looking for is a “Common Dialog Control”. The problem is : when I clik to add ths control to my form, I got this message : the control cannot be created because it is not properly licensed. I’ve asked for it on different forum and the problem seem to come from flexpro.Microsoft have a patch to solve this problem, but it need to have VB6.0 installed, not a VBA application.
http://support.microsoft.com/defaul…kb;EN-US;194751
Is there another way I can get my dialog window ?
ThanksJanuary 18, 2006 at 4:02 am #8692Bernhard KantzParticipantYou need a design-time license for the “Common Dialog Control”. This design time license comes together with VB 6.0, unfortunately not with VBA.
So if you have VB installed on your system you can use the control also in VBA. If you redistribute a VBA project which uses the control and you simply install (copy+register) the control on the target machine it will work fine at run-time. On the other hand you will not be able to add a new instance of the control on the target machine.To get the dialog box without the “Common Dialog Control” is possible, as the functionality is provided by a Windows API. This requires some more work, see for instance http://www.activevb.de/tipps/vb6tipps/tipp0368.html for a VB-example. This should basically work also with VBA.
Support
support@weisang.comJanuary 18, 2006 at 5:16 am #8693Nicolas BeaupréMemberThen, why is it possible to call this windows in word or excel VBA and not in flexpro ?
In excel, I open it with that line : Application.GetOpenFileName
And in word : Application.Dialogs(wdDialogFileOpen).Display
January 18, 2006 at 8:12 pm #8694Bernhard KantzParticipantThis is possible, because Word and Excel have (re-)implemented the Open-File-dialog-box functionality in their object model. As this is a rather generic functionality it is currently missing from the object model of FlexPro 7.0 (of cause it might be added in a future version).
As pointed out before it is no problem to use the Windows API directly. If you prefer an OCX based approach you might take a look at the pages of the Common Controls Replacement Project, especially at http://ccrp.mvps.org/controls/ccrpfiledlg5.htm.Support
support@weisang.comJanuary 18, 2006 at 11:34 pm #8695Nicolas BeaupréMemberThanks,
The API method is working fine!
January 18, 2006 at 11:48 pm #8696Nicolas BeaupréMemberIn the same kind, how is it possible to just select a path ? I would like the user to select an empty (or not) folder where he want a batch of files to be exported bye the VBA macro… The API function above only allow us to select a specific file, not a path.
(sorry I can’t dig myself on the website you gave me because I don’t know a word of German!)January 19, 2006 at 1:38 am #8697Bernhard KantzParticipantThe SHBrowseForFolder API can be used for folder selection. A Google search for “SHBrowseForFolder VBA” should reveal some application examples.
Support
support@weisang.comMarch 10, 2009 at 11:47 pm #8698Stefan PalaveevMemberThe API method from the page http://www.activevb.de/tipps/vb6tipps/tipp0368.html you refer to is not working because of:
What is an alternative handle, which works?
March 11, 2009 at 2:00 am #8699Bernhard KantzParticipantThis code is an example for Visual Basic. In VBA there is no window handle.
Try Nothing instead of Me.hWnd.March 12, 2009 at 8:31 pm #8700Stefan PalaveevMemberHi,
finally I was successful. For all of you having the same problems here the code for opening a common dialog windows for files and for folders.Private Declare Function GetOpenFileName Lib "comdlg32.dll" _ Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) _ As Long Declare Function SHGetPathFromIDList Lib "shell32.dll" _ Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _ ByVal pszPath As String) As Long Declare Function SHBrowseForFolder Lib "shell32.dll" _ Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long Private Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String Flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As String End Type Public Type BROWSEINFO hOwner As Long pidlRoot As Long pszDisplayName As String lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type Public Const OFN_ALLOWMULTISELECT As Long = &H200& Public Const OFN_CREATEPROMPT As Long = &H2000& Public Const OFN_ENABLEHOOK As Long = &H20& Public Const OFN_ENABLETEMPLATE As Long = &H40& Public Const OFN_ENABLETEMPLATEHANDLE As Long = &H80& Public Const OFN_EXPLORER As Long = &H80000 Public Const OFN_EXTENSIONDIFFERENT As Long = &H400& Public Const OFN_FILEMUSTEXIST As Long = &H1000& Public Const OFN_HIDEREADONLY As Long = &H4& Public Const OFN_LONGNAMES As Long = &H200000 Public Const OFN_NOCHANGEDIR As Long = &H8& Public Const OFN_NODEREFERENCELINKS As Long = &H100000 Public Const OFN_NOLONGNAMES As Long = &H40000 Public Const OFN_NONETWORKBUTTON As Long = &H20000 Public Const OFN_NOREADONLYRETURN As Long = &H8000& Public Const OFN_NOTESTFILECREATE As Long = &H10000 Public Const OFN_NOVALIDATE As Long = &H100& Public Const OFN_OVERWRITEPROMPT As Long = &H2& Public Const OFN_PATHMUSTEXIST As Long = &H800& Public Const OFN_READONLY As Long = &H1& Public Const OFN_SHAREAWARE As Long = &H4000& Public Const OFN_SHAREFALLTHROUGH As Long = 2& Public Const OFN_SHARENOWARN As Long = 1& Public Const OFN_SHAREWARN As Long = 0& Public Const OFN_SHOWHELP As Long = &H10& Public Function ShowOpen(Filter As String, Flags As Long, hWnd As Long) As String Dim Buffer As String Dim Result As Long Dim ComDlgOpenFileName As OPENFILENAME Buffer = String$(128, 0) With ComDlgOpenFileName .lStructSize = Len(ComDlgOpenFileName) .hwndOwner = hWnd .Flags = Flags .nFilterIndex = 1& .nMaxFile = Len(Buffer) .lpstrFile = Buffer .lpstrFilter = Filter End With Result = GetOpenFileName(ComDlgOpenFileName) If Result 0 Then ShowOpen = Left$(ComDlgOpenFileName.lpstrFile, _ InStr(ComDlgOpenFileName.lpstrFile, _ Chr$(0)) - 1) End If End Function Function GetDirectory(Msg) As String Dim bInfo As BROWSEINFO Dim path As String Dim r As Long, x As Long, pos As Integer With bInfo .pidlRoot = 0& .lpszTitle = Msg .ulFlags = &H1 End With x = SHBrowseForFolder(bInfo) path = Space$(512) r = SHGetPathFromIDList(ByVal x, ByVal path) If r Then pos = InStr(path, Chr$(0)) GetDirectory = Left(path, pos - 1) Else GetDirectory = "" End If End Function Sub ProgramStart() '-------- Choose a File---------------- Dim sFile As String Dim Filter As String, Flags As Long Flags = OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY Or _ OFN_PATHMUSTEXIST Filter = "FlexPro (*.fpd)" sFile = ShowOpen(Filter, Flags, 0) '------------------------------------------ '-------Choose a Folder------------- Dim sFolder As String sFolder = GetDirectory("Choose a Folder") '--------------------------------------- End Sub
-
AuthorPosts
- You must be logged in to reply to this topic.