ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   a button to open up "My Computer" on an excel sheet (https://www.excelbanter.com/excel-programming/337426-button-open-up-my-computer-excel-sheet.html)

DorisM

a button to open up "My Computer" on an excel sheet
 
I'm trying to create a command button using VBA in an excel sheet that opens
up "My Computer". So it will allow the user to go to whatever folder that
they have their file saved at. Similar to the "Open" command in most window
applications.

I'm at level I in VBA, so I'm not sure if this is possible.

Thank you.

Doris

Jake Marx[_3_]

a button to open up "My Computer" on an excel sheet
 
Hi Doris,

DorisM wrote:
I'm trying to create a command button using VBA in an excel sheet
that opens up "My Computer". So it will allow the user to go to
whatever folder that they have their file saved at. Similar to the
"Open" command in most window applications.

I'm at level I in VBA, so I'm not sure if this is possible.


The GetOpenFilename method will allow the user to select a file. Here's
some sample code that shows how to use it:

Sub DemoFileSelect()
Dim vResponse As Variant

vResponse = Application.GetOpenFilename( _
FileFilter:="Microsoft Excel Files (*.xls), *.xls", _
Title:="Please select your file")

If vResponse < False Then
MsgBox Prompt:="You selected '" & vResponse & "'.", _
Buttons:=vbOKOnly Or vbInformation
Else
MsgBox Prompt:="You cancelled.", _
Buttons:=vbOKOnly Or vbInformation
End If
End Sub

If you drop a CommandButton from the Control Toolbox onto your worksheet,
you can double-click it and call the demo from the

Private Sub CommandButton1_Click()
DemoFileSelect
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Dick Kusleika[_4_]

a button to open up "My Computer" on an excel sheet
 
Doris

Maybe the GetOpenFileName method will work for you.

http://www.dicks-blog.com/archives/2...topenfilename/


--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

DorisM wrote:
I'm trying to create a command button using VBA in an excel sheet
that opens up "My Computer". So it will allow the user to go to
whatever folder that they have their file saved at. Similar to the
"Open" command in most window applications.

I'm at level I in VBA, so I'm not sure if this is possible.

Thank you.

Doris




sebastienm

a button to open up "My Computer" on an excel sheet
 
Hi,

The GetOpenFileName function display the regular Open dialog and the user
can browse and choose a file. Once the user clicks Ok or Cancel, the
GetOpenFileName function returns a string containing the path+name of the
selected file (or False if the user clicked Cancel). Impoirtant: The function
doesn't open the file, it just retuns its path+name, so you need some
additional code to process the file (open it, print it, or whatever you need
to do). (see online help for more info)

1- in a module, add the code to let a user choose a file:
Sub UserChooseFile()
Dim f As Variant
f = Application.GetOpenFilename("Excel File (*.xl),*.xls", , "Open
dialog test")
If f < False Then
MsgBox "Open " & f
Else
MsgBox "the Open was cancelled"
End If
'***** add process code here ******
End Sub
2-on a sheet, add a button from the Forms toolbar (not the Control Toolbox
toolbar; menu View Toolbars Forms)
If the Macro dialog doesn't popup right away, just right click the button
and choose Assign Macro. There choose the UserChooseFile macro.

I hope this helps,
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"DorisM" wrote:

I'm trying to create a command button using VBA in an excel sheet that opens
up "My Computer". So it will allow the user to go to whatever folder that
they have their file saved at. Similar to the "Open" command in most window
applications.

I'm at level I in VBA, so I'm not sure if this is possible.

Thank you.

Doris


Tom Ogilvy

a button to open up "My Computer" on an excel sheet
 
fname = Application.GetOpenFileName()

shows the file open dialog and allows traversing directories to find or
establish the location of the file.

for saving

fName = Application.GetSaveAsFileName()

Note that neither of these open or save the file selected - they return the
fully qualified name as a string

--
Regards,
Tom Ogilvy


"DorisM" wrote in message
...
I'm trying to create a command button using VBA in an excel sheet that

opens
up "My Computer". So it will allow the user to go to whatever folder that
they have their file saved at. Similar to the "Open" command in most

window
applications.

I'm at level I in VBA, so I'm not sure if this is possible.

Thank you.

Doris




DorisM

a button to open up "My Computer" on an excel sheet
 
Thank you guys. It works.

Doris

"DorisM" wrote:

I'm trying to create a command button using VBA in an excel sheet that opens
up "My Computer". So it will allow the user to go to whatever folder that
they have their file saved at. Similar to the "Open" command in most window
applications.

I'm at level I in VBA, so I'm not sure if this is possible.

Thank you.

Doris



All times are GMT +1. The time now is 05:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com