Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Reference drive letter that can change

Thanks Dave, just the job. Rob

"Dave Peterson" wrote in message
...
If it's always under the \sales folder under the path that contains the
workbook
with the macro:

Sub OpenText()
Workbooks.OpenText Filename:=thisworkbook.path &
"\sales\SalesInfo.prn",
....

===
Ps. ThisWorkbook is one word.

ChDir ThisWorkbook.Path
or
ChDir ThisWorkbook.Path & "\Sales"

(+ is usually used for adding numbers. & is used for concatenating text.)


Rob wrote:

Hi, I'm using the following code to import a file SalesInfo but have run
into an issue where the file used to run this code resides in a different
directory EG c:\work\salesmodel.xls is where the excel file resides and
c:\work\sales\ folder is where the data file is stored.

I think I need to change my first row of code to included the folder
Sales

ChDir This Workbook.Path
to
ChDir This Workbook.Path+"/Sales" [this doesn't work]

Sub OpenText()
ChDir ThisWorkbook.Path
Workbooks.OpenText Filename:="SalesInfo.prn", Origin:=437, StartRow _
:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2),
Array(8,
1), Array( _
17, 3), Array(25, 1), Array(36, 1), Array(46, 1), Array(56, 9),
Array(61, 9))
End Sub

Thanks, Rob


--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Links to mapped drive change to refer to local hard drive SueD Links and Linking in Excel 1 May 8th 08 11:42 AM
Obtain drive letter assignment of CD/DVD drive? EagleOne Excel Discussion (Misc queries) 1 October 13th 06 01:27 PM
Help to Indentify a drive letter Grandad Excel Programming 12 August 6th 04 08:50 PM
Using path instead of drive letter dumbass Excel Programming 2 May 25th 04 12:25 AM
Find links with code; change from G drive to C drive Sandy[_3_] Excel Programming 4 July 26th 03 07:24 PM


All times are GMT +1. The time now is 11:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"