Prev: AddWindowsPrinterConnection, but the mapping is NOT stored inthe user profile
Next: Changes made to Outlook form don't stay with form when mailed.
From: c on 18 Mar 2010 07:17 same here as well. I've come across the following 4 options so far, and neither of them are yet reliable in win7: <Option 1> This returns error in both winXP and win7 when certain file is selected: Function Browse() Const sHandle=&H0 Const sText = "Browse" Const sOption=&H4000 Const sOption2=&H0001 Const iRoot = 0 Dim oS: Set oS=CreateObject("Shell.Application") Dim oF: Set oF=oS.BrowseForFolder(sHandle,sText,sOption,iRoot) Dim sF: sF=oF.self.path Browse=sF End Function It returns namespace value successfully when: 1. any folder is selected 2. any one of these file is selected(.zip, .pdf,..html) And it fails when: 1. any other file format is selected including (.txt, .doc, .xml, etc...) <Option 2> On the other hand, the following code works but only in XP, and not in Win7: Function Browse() Browse=Null Dim oCD: Set oCD=CreateObject("UserAccounts.CommonDialog") oCD.Filter = "Text Files|*.txt|All Files|*.*" oCD.FilterIndex = 1 oCD.InitialDir = "C:\" Dim iReturn: iReturn=oCD.ShowOpen If iReturn = 0 Then Exit Function Dim sFN: sFN=oCD.FileName Browse=sFN Set oCD = Nothing End Function Win 7 doesn't seem to come with the dll required to call UserAccounts.. <Option 3> Use of MSComDlg is not an option for me for the same reason listed by others. <Option 4> Use of IE seems to work fine in both WinXP and Win7, yet the speed is an issue as it hungs a bit while booting IE. Any advice? "jeng02" wrote: > Same here. I am programming in Office 2010 64-bit VBA on Windows 7 64-bit. > I can see individual files but when I select them it errors. It does not > error when I select folders or libraries. Error message is: Method > BrowseForFolder of object IShellDispatch5 failed. > Here is my code: > > Sub testopen() > Dim objShell As Object > Dim strPath As String > Dim objFile > Set objShell = CreateObject("Shell.Application") > 'Shows dialog but errors when you select a file: > Set objFile = objShell.BrowseForFolder(0, "Choose a file:", &H4000) > strPath = objFile.Title '& vbCrLf & objFile.self.Path > MsgBox strPath > Set objFile = Nothing > Set objShell = Nothing > End Sub > > "Kryten" wrote: > > > Thanks to everyone who replied. > > > > I have issues with the browseforfolder method. I had > > experimented with it before actually and was able to get > > it to expose files, OK but it always emits an error > > after selecting one of them. Never able to properly > > update the OpenfileDialog.Filename property. > > > > The IE method, for me runs but does not result > > in a filebrowser. Deconstructing the code I can > > certainly get the IE about:blank to show but the > > underlying functionality isn't there. Maybe because > > I'm using W7/IE7? Not sure. > > > > The jsware stuff looked really promising until I > > got the "Windows Vista is not supported exception". > > Looking around the jsware site it looks like I may > > be out of luck using these controls in Vista and W7 ;-) > > > > This may not be too much of a problem right now > > as the desktops I'm developing the script for all > > run XP/SP2 and will do till the end of this year. > > > > My scripting language of choice is actually Powershell, > > where thanks to applications like ASE and PrimalForms > > it's trivial to create Windows Forms Applications. > > > > It also makes instantiating .NET objects easy too. > > Such as $browse = new-object system.windows.forms.openfiledialog > > > > Any ideas, or boilerplate code for using that .NET object in > > VBScript ( Once it gets > 100 lines I lose interest though! ). > > > > Thanks again, > > Stuart > > >
From: mayayana on 18 Mar 2010 11:46
> <Option 4> > Use of IE seems to work fine in both WinXP and Win7, yet the speed is an > issue as it hungs a bit while booting IE. > You might check what extensions or BHOs are barnicled onto IE. If you use IE online it's easy to end up with all sorts of "toolbars" and other junk. They not only need to load, but some of them may also go online or do other setup operations when IE starts. Also check for problematic software running. (In my experience, the major AV programs like Norton and McAffee can slow things to a crawl.) Windows seems to get slower with each version, but I've used the IE dialogue on 98/XP quite a bit myself and I find it to be pretty much instant in its operation. (Without any special hardware: Athlon 1660 with 500 MB RAM and IDE drives.) In fact, that's all I use for File Open dialogues. Anything else, as you so thoroughly detailed, comes with caveats and limitations. XP is never as zippy as 98, even when it's running lean with few services, And Vista/7 is a whole other order of bloat -- 7-9 times the size of XP on disk. But you shouldn't be finding that IE takes a long time to load. Most of it is already loaded. You're only starting up iexplore.exe, which is just a "chrome" skin for the browser window. My experience with IE 7/8 is limited, mostly to test webpages, so I can't be sure about those. It'd be interesting to know if other people have found IE 7/8 too slow to be usable. |