Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default 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]

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a "Next" button to move the user to the next sheet Rob Excel Discussion (Misc queries) 2 March 29th 09 12:14 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Excel "Move or Copy" and "Delete" sheet functions dsiama Excel Worksheet Functions 1 December 28th 07 01:57 PM
Why can't I do a "basic search" of my computer in Excel 2007 Tom_in_New_Mexico New Users to Excel 0 May 15th 07 06:11 PM
set up a command button or macro for open file to "save as" Mo Excel Programming 1 June 23rd 05 12:19 AM


All times are GMT +1. The time now is 01:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"