|
-
Nov 23rd, 2005, 09:36 AM
#1
Thread Starter
Junior Member
Excel opening .txt file code?
Hi,
Can someone please help me with some simple vb code for my excel macro. I wish to open a .txt file which will have a specific name based on what is contained in a certain cell in my spreadsheet. Can this be done and if so what coding would I use? I can get the a .txt file to open based on renaming the file to a certain name but I wish to be able to tell it what the name is by typing text into a cell.
Thanks
-
Nov 23rd, 2005, 09:56 AM
#2
Thread Starter
Junior Member
Re: Excel opening .txt file code?
At the moment I have
Dim projectname As String
projectname = Range("C4")
Dim referenceid As String
referenceid = Range("C5")
Workbooks.OpenText FileName:= _
"C:\Documents and Settings\rkennedy\Desktop\" & projectname & "~" & referenceid & ".142", Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _
, Comma:=False, Space:=False, Other:=True, OtherChar:="=", FieldInfo _
:=Array(Array(1, 1), Array(2, 1))
This gives an error that it cannot find the file which will have the name cell1~cell2.142
-
Nov 23rd, 2005, 09:57 AM
#3
Re: Excel opening .txt file code?
Excel.Workbooks.Open "C:\path\" & Worksheets(1).Range("A1").Value
worked fine for me..
try doing it with a regular name file.. like Test.txt
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 23rd, 2005, 11:20 AM
#4
Re: Excel opening .txt file code?
Excel VBA question moved to Office Development.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|