Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello to all,
I´m triying to open a *.txt file in a variable path and with a variable name. C:\.....\year\weekXX\ After opening the select dialog box I select the *.txt file and convert with comma delimiters. -year- is the value of a cell in worksheet -weekXX- is the value of a cell in worksheet Thanks for your help |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Take a look at GetOpenFilename in VBA help.
-- HTH Bob Phillips "carloshernandezy" wrote in message ups.com... Hello to all, I´m triying to open a *.txt file in a variable path and with a variable name. C:\.....\year\weekXX\ After opening the select dialog box I select the *.txt file and convert with comma delimiters. -year- is the value of a cell in worksheet -weekXX- is the value of a cell in worksheet Thanks for your help |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello Bob,
I´ve been triying a code like this and it returns an error "13" in line Sub TXT_OPEN() Dim varDir, varYear, varWeek As String Dim ws As Workbook Dim RutaArchivo As String Set ws = ActiveWorkbook Application.DisplayAlerts = False varDir = "C:\....\VB\" varYear = Range("L8") varWeek = Range("L7") RutaArchivo = varYear & " \ " & varWeek ChDir " C:\....\VB\ varYear & " \ " & varWeek " archivoAAbrir = Application.GetOpenFilename("Archivos de texto (*.txt), *.txt") If archivoAAbrir < False Then ChDir " C:\....\VB\ " Workbooks.OpenText Filename:=archivoAAbrir, Origin:= _ xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _ Comma:=True, Space:=False, Other:=True, OtherChar:="|", 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)) End If End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can't use "C:\.....\
you have to put in the path explicitly. -- Regards, Tom Ogilvy "carloshernandezy" wrote in message ups.com... Hello Bob, I´ve been triying a code like this and it returns an error "13" in line Sub TXT_OPEN() Dim varDir, varYear, varWeek As String Dim ws As Workbook Dim RutaArchivo As String Set ws = ActiveWorkbook Application.DisplayAlerts = False varDir = "C:\....\VB\" varYear = Range("L8") varWeek = Range("L7") RutaArchivo = varYear & " \ " & varWeek ChDir " C:\....\VB\ varYear & " \ " & varWeek " archivoAAbrir = Application.GetOpenFilename("Archivos de texto (*.txt), *.txt") If archivoAAbrir < False Then ChDir " C:\....\VB\ " Workbooks.OpenText Filename:=archivoAAbrir, Origin:= _ xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _ Comma:=True, Space:=False, Other:=True, OtherChar:="|", 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)) End If End Sub |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom I Know it´s only an example, it is complete in the original code.
Thanks for your advice. Regards, |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
so this is your problem line?
ChDir " C:\....\VB\ varYear & " \ " & varWeek " Unless you just omitted and added double quotes arbitrarily as examples, then ChDir "C:\....\VB\" & varYear & " \ " & varWeek but since you did this RutaArchivo = varYear & " \ " & varWeek Why not just do ChDir "C:\....\VB\" & RutaArchivo -- Regards, Tom Ogilvy "carloshernandezy" wrote in message oups.com... Tom I Know it´s only an example, it is complete in the original code. Thanks for your advice. Regards, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
opening files simultaneously with same name but different path | Excel Discussion (Misc queries) | |||
Problem with references while opening Excel from IE using UNC path | Links and Linking in Excel | |||
Opening a document without adding the path | Excel Programming | |||
Opening a document without adding the path | Excel Programming | |||
Opening file through UNC path changes my links | Links and Linking in Excel |