Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to open a file that has a date in its name. EX Data-20070816.csv
I have the user input the date in one cell (a1) and have a string formula in another cell (b1). I keep getting an error when I try to define the variable. Windows("Data Comparison.xls").Activate Application.Run "BLPLinkReset" Sheets("Sheet1").Select Dim Filename As String Set Filename = Range("A1").Select Workbooks.Open Filename:="V:\FTP Data\(Filename)" |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes the file exists. I have strFilename1X.
"Jim Thomlinson" wrote: Where does the 1X come from. By prefixing FileName with "str" we get aound the reserved word issue. Does a file exist such as V:\FTP Data\Data-20070816.csv -- HTH... Jim Thomlinson "Amir" wrote: It errors out at the Filename:="V:\FTP Date\" & strFileName1X "Jim Thomlinson" wrote: Try this... Dim strFileName as String strFileName = Range("B1").Value Workbooks.Open Filename:="V:\FTP Data\" & strFileName Note - Don't declare a variable FileName as that is a reserved word(ish). -- HTH... Jim Thomlinson "Amir" wrote: I have it calling B1 "Amir" wrote: I am trying to open a file that has a date in its name. EX Data-20070816.csv I have the user input the date in one cell (a1) and have a string formula in another cell (b1). I keep getting an error when I try to define the variable. Windows("Data Comparison.xls").Activate Application.Run "BLPLinkReset" Sheets("Sheet1").Select Dim Filename As String Set Filename = Range("B1").Select Workbooks.Open Filename:="V:\FTP Data\(Filename)" |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Where does the 1X come from. By prefixing FileName with "str" we get aound
the reserved word issue. Does a file exist such as V:\FTP Data\Data-20070816.csv -- HTH... Jim Thomlinson "Amir" wrote: It errors out at the Filename:="V:\FTP Date\" & strFileName1X "Jim Thomlinson" wrote: Try this... Dim strFileName as String strFileName = Range("B1").Value Workbooks.Open Filename:="V:\FTP Data\" & strFileName Note - Don't declare a variable FileName as that is a reserved word(ish). -- HTH... Jim Thomlinson "Amir" wrote: I have it calling B1 "Amir" wrote: I am trying to open a file that has a date in its name. EX Data-20070816.csv I have the user input the date in one cell (a1) and have a string formula in another cell (b1). I keep getting an error when I try to define the variable. Windows("Data Comparison.xls").Activate Application.Run "BLPLinkReset" Sheets("Sheet1").Select Dim Filename As String Set Filename = Range("B1").Select Workbooks.Open Filename:="V:\FTP Data\(Filename)" |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Define variable from cell to open a file | Excel Programming | |||
Define variable from cell to open a file | Excel Programming | |||
open file (as variable) from macro | Excel Discussion (Misc queries) | |||
Syntax to define a variable for current file | Excel Programming | |||
Using a variable name as part of a file pathname to open many files | Excel Programming |