Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Help with text file

I need some help on this one...

I am trying to code a macro that will bring the same text file up and use
the fixed width method of text to columns. I have recorded the marco and
tried to figure the code based on that. Below is the recorded macro first,
followed by the code that I am building. Can some help mefill in the missing
pieces to the how the flow should be from the Dim to the Array?

Sub WPCOM()
'
' WPCOM Macro
' Macro recorded 3/15/2006 by ewagner
'

'
ChDir "G:\shared-drive\XXXX\XXXX\XX Sheets"
Workbooks.Open Filename:= _
"G:\XXXXX\XXXXX\XXXXX\XXXXX\XXXXX Mar-2006.xls"
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("MTD").Select
ActiveWindow.LargeScroll ToRight:=-1
ChDir "G:\COMMAND-CENTER\IEX LA info"
Workbooks.OpenText Filename:= _
"G:\XXXXX\XXXXX\XXXXX.xls", Origin:=xlWindows, _
StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1),
Array( _
165, 1), Array(174, 1), Array(182, 1))
ActiveWindow.LargeScroll Down:=1
Range("B62:B107").Select
Selection.Copy
ActiveWindow.ActivateNext
Range("B5").Select
Selection.PasteSpecial Paste:=xlValues
End Sub
___________________________

Sub WPCOM()

Dim LA As Workbook
Dim MTD As Worksheet
Dim IEX As Workbook
Dim WPCOM As Worksheet

Set LA = Workbooks.Open(Filename:= _
"G:\XXXX\XXXX\XXXX\XXXX\XXXX " & Format(Date, "mmm-yyyy") & ".xls")
Set MTD = LAWkbk.Worksheets("MTD")
Set IEX =

End Sub

The portion where the code ends is where I would imagine that the array code
would go to open the text file with the fixed width.

Thanks ahead of time for any help in the matter!
--
EW - Analyst
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Help with text file

No, opentext doesn't return a reference, so you can't do what you imagine:

Sub WPCOM()

Dim LA As Workbook
Dim MTD As Worksheet
Dim IEX As Workbook
Dim WPCOM As Worksheet

Set LA = Workbooks.Open(Filename:= _
"G:\XXXX\XXXX\XXXX\XXXX\XXXX " & Format(Date, "mmm-yyyy") & ".xls")
Set MTD = LAWkbk.Worksheets("MTD")
OpenText blah blah blah
Set IEX = Activeworkbook

End Sub

--
Regards,
Tom Ogilvy



"ewagz" wrote:

I need some help on this one...

I am trying to code a macro that will bring the same text file up and use
the fixed width method of text to columns. I have recorded the marco and
tried to figure the code based on that. Below is the recorded macro first,
followed by the code that I am building. Can some help mefill in the missing
pieces to the how the flow should be from the Dim to the Array?

Sub WPCOM()
'
' WPCOM Macro
' Macro recorded 3/15/2006 by ewagner
'

'
ChDir "G:\shared-drive\XXXX\XXXX\XX Sheets"
Workbooks.Open Filename:= _
"G:\XXXXX\XXXXX\XXXXX\XXXXX\XXXXX Mar-2006.xls"
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("MTD").Select
ActiveWindow.LargeScroll ToRight:=-1
ChDir "G:\COMMAND-CENTER\IEX LA info"
Workbooks.OpenText Filename:= _
"G:\XXXXX\XXXXX\XXXXX.xls", Origin:=xlWindows, _
StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1),
Array( _
165, 1), Array(174, 1), Array(182, 1))
ActiveWindow.LargeScroll Down:=1
Range("B62:B107").Select
Selection.Copy
ActiveWindow.ActivateNext
Range("B5").Select
Selection.PasteSpecial Paste:=xlValues
End Sub
___________________________

Sub WPCOM()

Dim LA As Workbook
Dim MTD As Worksheet
Dim IEX As Workbook
Dim WPCOM As Worksheet

Set LA = Workbooks.Open(Filename:= _
"G:\XXXX\XXXX\XXXX\XXXX\XXXX " & Format(Date, "mmm-yyyy") & ".xls")
Set MTD = LAWkbk.Worksheets("MTD")
Set IEX =

End Sub

The portion where the code ends is where I would imagine that the array code
would go to open the text file with the fixed width.

Thanks ahead of time for any help in the matter!
--
EW - Analyst

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Help with text file

Does this open the array in the text files....sorry, I'm not understanding
--
EW - Analyst


"Tom Ogilvy" wrote:

No, opentext doesn't return a reference, so you can't do what you imagine:

Sub WPCOM()

Dim LA As Workbook
Dim MTD As Worksheet
Dim IEX As Workbook
Dim WPCOM As Worksheet

Set LA = Workbooks.Open(Filename:= _
"G:\XXXX\XXXX\XXXX\XXXX\XXXX " & Format(Date, "mmm-yyyy") & ".xls")
Set MTD = LAWkbk.Worksheets("MTD")
OpenText blah blah blah
Set IEX = Activeworkbook

End Sub

--
Regards,
Tom Ogilvy



"ewagz" wrote:

I need some help on this one...

I am trying to code a macro that will bring the same text file up and use
the fixed width method of text to columns. I have recorded the marco and
tried to figure the code based on that. Below is the recorded macro first,
followed by the code that I am building. Can some help mefill in the missing
pieces to the how the flow should be from the Dim to the Array?

Sub WPCOM()
'
' WPCOM Macro
' Macro recorded 3/15/2006 by ewagner
'

'
ChDir "G:\shared-drive\XXXX\XXXX\XX Sheets"
Workbooks.Open Filename:= _
"G:\XXXXX\XXXXX\XXXXX\XXXXX\XXXXX Mar-2006.xls"
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("MTD").Select
ActiveWindow.LargeScroll ToRight:=-1
ChDir "G:\COMMAND-CENTER\IEX LA info"
Workbooks.OpenText Filename:= _
"G:\XXXXX\XXXXX\XXXXX.xls", Origin:=xlWindows, _
StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1),
Array( _
165, 1), Array(174, 1), Array(182, 1))
ActiveWindow.LargeScroll Down:=1
Range("B62:B107").Select
Selection.Copy
ActiveWindow.ActivateNext
Range("B5").Select
Selection.PasteSpecial Paste:=xlValues
End Sub
___________________________

Sub WPCOM()

Dim LA As Workbook
Dim MTD As Worksheet
Dim IEX As Workbook
Dim WPCOM As Worksheet

Set LA = Workbooks.Open(Filename:= _
"G:\XXXX\XXXX\XXXX\XXXX\XXXX " & Format(Date, "mmm-yyyy") & ".xls")
Set MTD = LAWkbk.Worksheets("MTD")
Set IEX =

End Sub

The portion where the code ends is where I would imagine that the array code
would go to open the text file with the fixed width.

Thanks ahead of time for any help in the matter!
--
EW - Analyst

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
How to tell number of spaces between values in saved text file fromthe original xls file [email protected] Excel Discussion (Misc queries) 1 January 15th 08 11:52 AM
Saving multi-tab excel file created from comma delimited text file Marcus Aurelius Excel Programming 2 December 19th 05 05:16 PM
How do I import text file, analyze data, export results, open next file Geoffro Excel Programming 2 March 6th 05 08:02 PM
Excel VBA - open text file, replace text, save file? Cybert Excel Programming 2 October 2nd 04 01:05 AM
importing text file, removing data and outputting new text file Pal Excel Programming 8 February 27th 04 08:32 PM


All times are GMT +1. The time now is 09:38 AM.

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"