Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA Code Question

Hello:

I have a macro that opens a specific file. I want the
macro to open any filename that I specify in a popup
box. Does anyone know how I can accomplish this?

Any help would be great.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default VBA Code Question



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Theresa" wrote in message
...
Hello:

I have a macro that opens a specific file. I want the
macro to open any filename that I specify in a popup
box. Does anyone know how I can accomplish this?

Any help would be great.

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default VBA Code Question

Theresa,

Something like

sName = Inputbox("Please supply filename")
Workbooks.Open Filename:=sName

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Theresa" wrote in message
...
Hello:

I have a macro that opens a specific file. I want the
macro to open any filename that I specify in a popup
box. Does anyone know how I can accomplish this?

Any help would be great.

Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default VBA Code Question

Theresa,

Try something like the following:

Dim FName As Variant
FName = Application.GetOpenFilename("Excel files (*.xls),*.xls")
If FName = False Then
' user clicked cancel
Else
Workbooks.Open FName
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Theresa" wrote in message
...
Hello:

I have a macro that opens a specific file. I want the
macro to open any filename that I specify in a popup
box. Does anyone know how I can accomplish this?

Any help would be great.

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default VBA Code Question

Try this with GetOpenFilename

Sub testing()
Dim FName As Variant
Dim N As Long
Dim S As String
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls", _
MultiSelect:=True)

If IsArray(FName) Then
For N = LBound(FName) To UBound(FName)
Workbooks.Open (FName(N))
Next
End If
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Theresa" wrote in message ...
Hello:

I have a macro that opens a specific file. I want the
macro to open any filename that I specify in a popup
box. Does anyone know how I can accomplish this?

Any help would be great.

Thanks





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA Code Question

Chdrive "C"
ChDir "C:\My Folder"
fName = Application.GetOpenFilename()
if fName < false then
workbooks.open fName
End Sub

--
Regards,
Tom Ogilvy

"Theresa" wrote in message
...
Hello:

I have a macro that opens a specific file. I want the
macro to open any filename that I specify in a popup
box. Does anyone know how I can accomplish this?

Any help would be great.

Thanks



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default VBA Code Question

Hi Theresa,

Try this code at the top of of your macro and it should allow you to
open up any file as it prompts you to select the file you want to use.
So just incase you don't remeber the name of the file. Excel will do an
open file function and you can pick the file you want.

myFile = Application.GetOpenFilename("Excel Files, *.xls")

Hope it works and good luck.

Oli

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
VBA code question peyman Excel Discussion (Misc queries) 5 February 5th 09 12:04 AM
vb code question Stan Excel Discussion (Misc queries) 0 April 28th 08 04:43 PM
vb code question Stan Excel Discussion (Misc queries) 8 April 25th 08 10:43 PM
VB Code Question Stan Excel Discussion (Misc queries) 6 April 30th 07 11:27 PM
VBA code question JEV Excel Discussion (Misc queries) 2 March 1st 07 06:02 PM


All times are GMT +1. The time now is 01:27 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"