L
louishong
Hello,
i have a simple macro that pulling in a text file:
Public Function Import_FND_GFM_BV(DataPathName, TemplateBook)
Application.StatusBar = "Importing fnd_gfm-BV.tsv..."
ChDir DataPathName
'Open BV.txt
Workbooks.OpenText Filename:="fnd_gfm-BV.tsv" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited,
TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array
(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6,
1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array
(13, 1), Array(14, 1), Array(15 _
, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1),
Array(20, 1), Array(21, 1)), _
TrailingMinusNumbers:=True
Cells.Select
Cells.EntireColumn.AutoFit
DataWorkbook = ActiveWorkbook.Name
'Copy data
Range("B60000").Select
Selection.End(xlUp).Select
Range(Selection, "T2").Copy
'Paste data
Workbooks(TemplateBook).Activate
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Paste:=xlPasteFormats
Workbooks(DataWorkbook).Close
End Function
When I run it on drive C: (anywhere) it runs fine on any machine but
if I try to run the same Excel program on Drive D: or any network
drives I get a run-time error 1004...'fnd_gfm-BV.tsv' could not be
found. check the spelling of the file name, and verify that the file
location is correct.
When I check the DataPathName value in the immediate window the path
is correct and the file name is correct. This program seems to only
want to work from drive C:...it's got us stumped. Any suggestions
would be greatly appreciate it.
TIA
i have a simple macro that pulling in a text file:
Public Function Import_FND_GFM_BV(DataPathName, TemplateBook)
Application.StatusBar = "Importing fnd_gfm-BV.tsv..."
ChDir DataPathName
'Open BV.txt
Workbooks.OpenText Filename:="fnd_gfm-BV.tsv" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited,
TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array
(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6,
1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array
(13, 1), Array(14, 1), Array(15 _
, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1),
Array(20, 1), Array(21, 1)), _
TrailingMinusNumbers:=True
Cells.Select
Cells.EntireColumn.AutoFit
DataWorkbook = ActiveWorkbook.Name
'Copy data
Range("B60000").Select
Selection.End(xlUp).Select
Range(Selection, "T2").Copy
'Paste data
Workbooks(TemplateBook).Activate
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Paste:=xlPasteFormats
Workbooks(DataWorkbook).Close
End Function
When I run it on drive C: (anywhere) it runs fine on any machine but
if I try to run the same Excel program on Drive D: or any network
drives I get a run-time error 1004...'fnd_gfm-BV.tsv' could not be
found. check the spelling of the file name, and verify that the file
location is correct.
When I check the DataPathName value in the immediate window the path
is correct and the file name is correct. This program seems to only
want to work from drive C:...it's got us stumped. Any suggestions
would be greatly appreciate it.
TIA