Getopenfilename Default File Path Example

I have some applications (Quickwin) that use the API function GetOpenFileName, called with a derived-type structure OFN. Up pops a window showing files, matching a filter, for the user to select.

Getopenfilename Default File Path ExampleGetopenfilename Default File Path Example

The view has always been in the 'list' format, in Windows Vista, 7 and 8.1. Since changing to Windows 10, the view is in 'icon' format instead. How can I force it to be in list mode?Looking at some sample code on the net, I am led to believe the OFN structure may contain a member named DialogView or something like that; or, the Flags member may offer a setting called OFNList or something like that (along with OFNLargeIcon, OFNSmallIcon, OFNThumbnails, etc.). But I could not comprehend the code sample (nearly 400 lines just to call GetOpenFileName!) and I cannot find documentation of these alleged features.Can anybody help? Lest I resort to trial and (mostly) error! Further testing yields results (at least sometimes).I have tried presetting the View properties in File Explorer, both on the default folder and the folder that my application usually accesses. Had no effect (sorry Ian and Steve).But duh.the GetOpenFileName window has at the top a 'mini ribbon' that has a View options dropdown for user control.

I have always ignored this feature because the default View property always seemed to be what I wanted. How this setting got changed to Icons by default is beyond me-apparently just a 'new feature' of Windows 10 as Steve suggested. If I use this dropdown to choose List, then that will stick.That said, since the View setting appears to be a property of GetOpenFileName that the user can select, it seems that a developer should be able to control it programmatically. The code I found on the net may be a white elephant, appearing to use a variable ofnlist to do this. But I can find no other documentation of this, and I cannot make it work. I haven't tried GetOpenFileName on Windows 10, but if it works similar to the older Windows Explorer, it may have its own viewing preference different from Windows Explorer.

If I were to guess how to set the default preference it would beProgrammically call GetOpenFileName with the options that enable the tool bar.Navigate to the folder of interest.Set view to details (assuming this is available). Navigate off of that folderOpen some arbitrary file (which may be back in the desired folder)Take a normal exit of your application.IOW do not cancel the GetOpenFileName dialog.It may be the case that the noob writing the MS dialog only uses his phone to browse icons. (much like that stupid banner at the bottom of this page which occults this edit box and Submit button).Jim Dempsey.

Context: My goal is to update links between PPT and Excel, and have the user select the new file to link to. We have monthly files with just the numbers changing (eg, table sizes are all fixed).I'm trying to set the default directory that Excel shows when using the GetOpenFilename. The trick is my code is in PowerPoint, and I am opening the Excel file with the CreateObject('Excel.Applic ation'). The code I tried is here, but when it opens the GetOpenFilename, it goes only to MyDocuments:Set exl = CreateObject('Excel.Applic ation')ChDrive Left(ActivePresentation.Pa th, 2)strNewDrive = Left(ActivePresentation.Pa th, 2)ChDir ActivePresentation.PathstrNewDir = ActivePresentation.PathExcelFileNew = exl.Application.GetOpenFil ename(, 'Select Excel File')' The rest of the code is a bit clumsy, but attached.

Getopenfilename Win32

I use GetSetting and SaveSetting to store MRU paths for this purpose. That way you can access the paths from any Office app hosting VBA. If you just need to select an Excel File maybe this would work in PPT (The code does not seem to be attached BTW)Dim exl As ObjectDim fd As FileDialogDim strFilename As StringSet exl = CreateObject('Excel.Applic ation')Set fd = PowerPoint.Application.Fil eDialog(ms oFileDialo gOpen)With fd.AllowMultiSelect = False.Filters.Clear.Filters.Add 'Excel Files', '.xls,.xlsx'.InitialFileName = 'C:UsersOptiplexDesktop 'If.Show = True ThenstrFilename =.SelectedItems(1)End IfEnd WithMsgBox 'Path= ' & strFilenameMsgBox 'Filename= ' & Right(strFilename, Len(strFilename) - InStrRev(strFilename, ')).