Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Open, Save and close Excel 2007 file with a cmd command | Excel Discussion (Misc queries) | |||
Macro to Open, then Close another File | Excel Discussion (Misc queries) | |||
Delete/Close Excel file that is kept OPEN | New Users to Excel | |||
Open excel file, enter values, save & close | Excel Programming | |||
Automate open file, update links, run macro, close and save file | Excel Programming |