Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Macro to open and close an Excel file

I would like to create a macro that would open an Excel file based on file
path that is indicated in a cell, and then close it. For instance, open the
file for which the file path is indicated in cell A1, and then close it.

Any advice you could provide on this would be greatly appreciated.

Magnivy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro to open and close an Excel file

workbooks.open Range("A1").Value
...
activeworkbook.close

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Magnivy" wrote in message
...
I would like to create a macro that would open an Excel file based on file
path that is indicated in a cell, and then close it. For instance, open

the
file for which the file path is indicated in cell A1, and then close it.

Any advice you could provide on this would be greatly appreciated.

Magnivy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Macro to open and close an Excel file

Hi, try this:

Sub File_Open()
file=Range("A1")
Workbooks.Open Filename:= file
ActiveWindow.Close
End Sub

€žMagnivy" napĂ*sal (napĂ*sala):

I would like to create a macro that would open an Excel file based on file
path that is indicated in a cell, and then close it. For instance, open the
file for which the file path is indicated in cell A1, and then close it.

Any advice you could provide on this would be greatly appreciated.

Magnivy

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Macro to open and close an Excel file

Try this...

Sub OpenClose()
Dim wbk As Workbook

On Error Resume Next
Set wbk = Workbooks.Open(Sheets("Sheet1").Range("A1"))
On Error GoTo 0

If wbk Is Nothing Then Exit Sub

MsgBox wbk.Name & " is open."
wbk.Close

MsgBox "And now it is closed."
Set wbk = Nothing
End Sub
--
HTH...

Jim Thomlinson


"Magnivy" wrote:

I would like to create a macro that would open an Excel file based on file
path that is indicated in a cell, and then close it. For instance, open the
file for which the file path is indicated in cell A1, and then close it.

Any advice you could provide on this would be greatly appreciated.

Magnivy

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to open and close an Excel file


dim openwb as workbook
workbooks.open filename:=Range("A1")
set openwb=activeworkbook
openwb.close

Magnivy Wrote:
I would like to create a macro that would open an Excel file based on
file
path that is indicated in a cell, and then close it. For instance, open
the
file for which the file path is indicated in cell A1, and then close
it.

Any advice you could provide on this would be greatly appreciated.

Magnivy



--
kwiklearner
------------------------------------------------------------------------
kwiklearner's Profile: http://www.excelforum.com/member.php...o&userid=31909
View this thread: http://www.excelforum.com/showthread...hreadid=521717



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Macro to open and close an Excel file

Many thanks to everyone for your help!! kwiklearner's code seems to work best
for me.

Magnivy
"kwiklearner" wrote:


dim openwb as workbook
workbooks.open filename:=Range("A1")
set openwb=activeworkbook
openwb.close

Magnivy Wrote:
I would like to create a macro that would open an Excel file based on
file
path that is indicated in a cell, and then close it. For instance, open
the
file for which the file path is indicated in cell A1, and then close
it.

Any advice you could provide on this would be greatly appreciated.

Magnivy



--
kwiklearner
------------------------------------------------------------------------
kwiklearner's Profile: http://www.excelforum.com/member.php...o&userid=31909
View this thread: http://www.excelforum.com/showthread...hreadid=521717


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
Open, Save and close Excel 2007 file with a cmd command Hugo Pinto Excel Discussion (Misc queries) 5 March 3rd 08 10:05 PM
Macro to Open, then Close another File HROBERTSON Excel Discussion (Misc queries) 1 January 8th 07 06:41 PM
Delete/Close Excel file that is kept OPEN Jafer New Users to Excel 0 April 15th 05 05:34 AM
Open excel file, enter values, save & close JCanyoneer Excel Programming 5 April 4th 05 04:40 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


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