Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a button to open a file

I will regularly be downloading new Excel spreadsheets to my desktop
but will need to run the same macro (that i have recently created) o
each file.

What I'm thinking is that I will create a file on my desktop that ha
the macro saved there, plus a button on Sheet 1 that will allow th
user (sometimes a coworker who doesn't understand this stuff) to jus
go get the downloaded file and pull it into that doc. Then, the use
could use the keyboard shortcut to run the macro.

Any suggestions on how to create this button and the underlying VB t
get the user to the "Open file" area?

Thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a button to open a file

top.

Can no one help with this

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Creating a button to open a file

How about recording a macro when you do it once manually?

Then you could edit that macro to make it more generic.

When you recorded your macro, you got something that looked like:

Option Explicit
Sub Macro1()

Workbooks.Open Filename:="C:\My Documents\excel\book2.xls"

End Sub

Well, instead of having your filename in the code, you can give the user a
chance to pick it themselves (take a look at getopenfilename in VBA's help):

Sub macro1A()

Dim myFileName As Variant

myFileName = Application.GetOpenFilename(filefilter:="Excel files, *.xls", _
Title:="Pick a File")

If myFileName = False Then
MsgBox "Ok, try later" 'user hit cancel
Exit Sub
End If

Workbooks.Open Filename:=myFileName '....rest of recorded code here!

End Sub


"ktpack <" wrote:

top.

Can no one help with this?

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

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
need macro from button to open selectable file dillon26 Excel Worksheet Functions 1 February 8th 09 09:55 AM
how to get a button added to a speardsheet to open another file? RS Excel Discussion (Misc queries) 1 April 10th 08 04:39 PM
button to open a file kolbydayne[_2_] Excel Programming 2 August 6th 04 03:36 AM
Create button to open a file kolbydayne Excel Programming 0 August 5th 04 04:55 PM
VBA - on a button event, open another closed file, post changes, close file Fio Excel Programming 0 March 1st 04 01:08 PM


All times are GMT +1. The time now is 11:37 PM.

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

About Us

"It's about Microsoft Excel"