#1
|
|||
|
|||
Visio VBA - Find file button...
Hi team
I'm using VBA in Visio 64 bit Plan 2 (I'm assuming this is the O365 version). I want a button that when I click allows me to select a (ideally Excel only) file similar to if I'm using file explorer (this would then show the directory and file name of the selected file in a text box, and this will allow me to then open the file with other vba code). But I'm struggling to find out how this is down. Any help gratefully received Many thanks James |
#2
|
||||
|
||||
It is odd that Visio doesn't allow the usual vba file picker dialogs.
The first solution posted by PatricK in this thread works for my 32bit Visio and someone posted that it worked on a 64 bit version too. vba - VBScript to open a dialog to select a filepath - Stack Overflow Using that code I adapted it to test Code:
Sub VisioFilePicker() Dim wShell As Object, sPath As String, oExec As Variant Set wShell = CreateObject("WScript.Shell") Set oExec = wShell.Exec("mshta.exe ""about:<input type=file id=FILE><script>FILE.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);</script>""") sPath = oExec.StdOut.ReadLine Debug.Print sPath End Sub I saw other solutions that make use of other Office applications to show the dialog. These allow filtering and setting default directories but would be slow to initiate. See open a fileDialog in visio vba - Stack Overflow as an example. Yet other approaches use CommonDialogs but I think this is more likely to fail on 64bit machines. Add Open File Dialog to VBA
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Thank you...
Nice one Andrew. Thanks for your time posting this.
James |
Tags |
visio vba macros |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Visio crashed & now file is blank | Moorhs | Visio | 1 | 12-27-2021 08:49 AM |
Find the appropriate visio diagram | nightearth | Visio | 1 | 08-02-2021 04:10 PM |
Link image from file into Visio | Vind | Visio | 0 | 11-08-2018 12:11 AM |
Rename visio file & hyperlink | O'Neill | Visio | 0 | 05-08-2016 11:43 PM |
How do you find what command a toolbar button represents? | New Daddy | Word | 6 | 05-05-2012 12:35 PM |