Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open File Marco
Dear Expert,
Say B4 cells contains a text C:\marco\main\help\income2009.xls How is the VB script so that once I run the marco it will open the file in accordance to the text in cell please ? In future, I change the text in B4 to C:\marco\main\help\expense2009.xls That marco can help me open that file too. It is not a fixed file name and thus fixed VB script. File name (to be opened) in cell B4 will be changed from time to time. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open File Marco
Try something like Dim S As String S = Range("B4").Text If S < vbNullString Then If Dir(S) < vbNullString Then Workbook.Open S Else Debug.Print "File '" & S & "' does not exist. End If Else Debug.Print "B4 is blank" End If Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Sun, 26 Apr 2009 06:13:01 -0700, Elton Law wrote: Dear Expert, Say B4 cells contains a text C:\marco\main\help\income2009.xls How is the VB script so that once I run the marco it will open the file in accordance to the text in cell please ? In future, I change the text in B4 to C:\marco\main\help\expense2009.xls That marco can help me open that file too. It is not a fixed file name and thus fixed VB script. File name (to be opened) in cell B4 will be changed from time to time. Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open File Marco
Hi,
Try this Workbooks.Open Filename:=Sheets("Sheet1").Range("B4").Value Mike "Elton Law" wrote: Dear Expert, Say B4 cells contains a text C:\marco\main\help\income2009.xls How is the VB script so that once I run the marco it will open the file in accordance to the text in cell please ? In future, I change the text in B4 to C:\marco\main\help\expense2009.xls That marco can help me open that file too. It is not a fixed file name and thus fixed VB script. File name (to be opened) in cell B4 will be changed from time to time. Thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open File Marco
I have tested ....
Both of you are very strong .... Great ... Thanks so much !!! "Chip Pearson" wrote: Try something like Dim S As String S = Range("B4").Text If S < vbNullString Then If Dir(S) < vbNullString Then Workbook.Open S Else Debug.Print "File '" & S & "' does not exist. End If Else Debug.Print "B4 is blank" End If Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Sun, 26 Apr 2009 06:13:01 -0700, Elton Law wrote: Dear Expert, Say B4 cells contains a text C:\marco\main\help\income2009.xls How is the VB script so that once I run the marco it will open the file in accordance to the text in cell please ? In future, I change the text in B4 to C:\marco\main\help\expense2009.xls That marco can help me open that file too. It is not a fixed file name and thus fixed VB script. File name (to be opened) in cell B4 will be changed from time to time. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Marco for printing to file/saving to file | Excel Programming | |||
Marco To Save Column A7 As A .txt File. | Excel Worksheet Functions | |||
How: Marco on Pivot Table to save as file up to 300 files | Excel Programming | |||
Marco Run on File Close | Excel Programming | |||
save file via Marco | Excel Programming |