Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Opening & Reading file in notepad then pasting into excel using VB

Thanks for the replys

Yes that code opened the variable perfectly thanks :)

im curious on this 'ReadLine' code, would this be able to read the
text in the notepad and paste contents into excel cells the way i need
it to? Also there are parts like MR
A B, these would need to be trimmed down to
just the characters and pasted into cells.
Thanks again.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Opening & Reading file in notepad then pasting into excel usin

Sorry, I missed the part in your post where you said you wanted to read the
text file and paste into Excel. I couldn't clearly understand the logic
based on your sample data and expected output.. but it looks like you'll need
to code your own parsing logic and then paste into Excel. So, maybe
something like this could get you started. The code below will read the text
file one line at a time and then paste each line in column A of a new
sheet... you'll need to tweak the code so that you can parse each line and
put each piece in the right place.


Sub test()
Dim gff_location As String

Dim oFSO As Object
Dim ts As Object

Dim strLine As String
Dim lRow As Long

gff_location = "C:\sample.txt"
Set oFSO = CreateObject("Scripting.FileSystemObject")

lRow = 1
If oFSO.FileExists(gff_location) Then

'read the text file
Set ts = oFSO.OpenTextFile(gff_location)

'create a new worksheet
'the new sheet will become the active one
Sheets.Add

While Not ts.AtEndOfStream
strLine = ts.ReadLine

'you need to parse the line according to
'your logic first before
'putting them in the worksheet
'this sample just puts each line in column A

ActiveSheet.Range("A" & lRow).Value = strLine
lRow = lRow + 1
Wend

Else
MsgBox gff_location & " file not found!"
End If

End Sub

--
Hope that helps.

Vergel Adriano


"DJ MC" wrote:

Thanks for the replys

Yes that code opened the variable perfectly thanks :)

im curious on this 'ReadLine' code, would this be able to read the
text in the notepad and paste contents into excel cells the way i need
it to? Also there are parts like MR
A B, these would need to be trimmed down to
just the characters and pasted into cells.
Thanks again.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Opening & Reading file in notepad then pasting into excel usin

Thanks for the help it worked nicely and gave good grounds to carry on
with.

im now putting line contents into its cells no problem, its just
the .GFF file seems to always be on top of the excel sheet, is there
any way of putting this in the background and still reading from it?
i have a date checker in place which checks the date on a spacific
line, if the date in the file is less than the current date a yes/no
box appears, the user cannot see this box as the .GFF file is still as
the front of the screen.

Application.ScreenUpdating = False doesnt seem to do the trick

Thanks again!

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
Notepad or .txt file to excel nathan Excel Worksheet Functions 3 December 1st 09 09:44 PM
Opening and reading a higher version of Excel Dave Peterson Excel Discussion (Misc queries) 0 February 25th 08 02:41 PM
Opening Notepad application from Excel macro Rafael Excel Programming 5 October 9th 06 03:09 PM
reading from another file and pasting to current file, "combobox" Darius New Users to Excel 1 September 26th 05 07:13 AM
Pasting from Notepad Al Excel Discussion (Misc queries) 1 June 14th 05 02:41 AM


All times are GMT +1. The time now is 11:56 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"