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 notepad file then sending to back

I have a piece of code which opens a certain notepad file, goes to a
line of the file, reads the date which is on that line then brings up
a message box if the date is in the past, the only problem with this i
have is when its doing the check, the notepad is above excel, so if
the message box tries to display, notepad is in the way and all excel
does is flash. i need to somehow send the notepad to the background
behind excel but still be able to read from it. any help?
heres my code:

Application.ScreenUpdating = False
Shell "Notepad.exe " & OpenFile, vbNormalFocus

Set oFSO = CreateObject("Scripting.FileSystemObject")
lRow = 1
If oFSO.FileExists(OpenFile) Then
Set GFF_File = oFSO.OpenTextFile(OpenFile)

strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine

DateCheck1st = Mid(strLine, 11, 8)
DateCheck2nd = Mid(DateCheck1st, 7, 2)
DateCheck3rd = Mid(DateCheck1st, 5, 2)
DateCheck4th = Mid(DateCheck1st, 1, 4)

DateCheck = DateCheck2nd & "/" & DateCheck3rd & "/" & DateCheck4th

If DateCheck Date Then
YesNoQuestion = "Date of .GFF file is " & DateCheck & " are you
sure you want to process this file?"
answer = MsgBox(YesNoQuestion, vbQuestion + vbYesNo)
End If
If answer = vbNo Then
Reset
Exit Sub
End If

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Opening notepad file then sending to back

Unless you need notepad open for some other reason besides extracting line 7
as a text string, you don't need to use it.

If OpenFile is the full path and file name of the text file you're checking,
try something like:

____________________________________

Const ForReading = 1

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTxtFile = oFSO.OpenTextFile(OpenFile, ForReading)

For x = 1 To 6
oTxtFile.ReadLine
Next

strLine = oTxtFile.ReadLine

oTxtFile.Close
_____________________________________

Now, strLine is the text from line 7 and you can check it for the date value
and you didn't need Notepad to be launched at all.


Steve



"DJ MC" wrote in message
oups.com...
I have a piece of code which opens a certain notepad file, goes to a
line of the file, reads the date which is on that line then brings up
a message box if the date is in the past, the only problem with this i
have is when its doing the check, the notepad is above excel, so if
the message box tries to display, notepad is in the way and all excel
does is flash. i need to somehow send the notepad to the background
behind excel but still be able to read from it. any help?
heres my code:

Application.ScreenUpdating = False
Shell "Notepad.exe " & OpenFile, vbNormalFocus

Set oFSO = CreateObject("Scripting.FileSystemObject")
lRow = 1
If oFSO.FileExists(OpenFile) Then
Set GFF_File = oFSO.OpenTextFile(OpenFile)

strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine

DateCheck1st = Mid(strLine, 11, 8)
DateCheck2nd = Mid(DateCheck1st, 7, 2)
DateCheck3rd = Mid(DateCheck1st, 5, 2)
DateCheck4th = Mid(DateCheck1st, 1, 4)

DateCheck = DateCheck2nd & "/" & DateCheck3rd & "/" & DateCheck4th

If DateCheck Date Then
YesNoQuestion = "Date of .GFF file is " & DateCheck & " are you
sure you want to process this file?"
answer = MsgBox(YesNoQuestion, vbQuestion + vbYesNo)
End If
If answer = vbNo Then
Reset
Exit Sub
End If



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Opening notepad file then sending to back

Is there a reason you even use/show notepad? The real work isn't done in
Notepad. It's done through your FSO code.

DJ MC wrote:

I have a piece of code which opens a certain notepad file, goes to a
line of the file, reads the date which is on that line then brings up
a message box if the date is in the past, the only problem with this i
have is when its doing the check, the notepad is above excel, so if
the message box tries to display, notepad is in the way and all excel
does is flash. i need to somehow send the notepad to the background
behind excel but still be able to read from it. any help?
heres my code:

Application.ScreenUpdating = False
Shell "Notepad.exe " & OpenFile, vbNormalFocus

Set oFSO = CreateObject("Scripting.FileSystemObject")
lRow = 1
If oFSO.FileExists(OpenFile) Then
Set GFF_File = oFSO.OpenTextFile(OpenFile)

strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine

DateCheck1st = Mid(strLine, 11, 8)
DateCheck2nd = Mid(DateCheck1st, 7, 2)
DateCheck3rd = Mid(DateCheck1st, 5, 2)
DateCheck4th = Mid(DateCheck1st, 1, 4)

DateCheck = DateCheck2nd & "/" & DateCheck3rd & "/" & DateCheck4th

If DateCheck Date Then
YesNoQuestion = "Date of .GFF file is " & DateCheck & " are you
sure you want to process this file?"
answer = MsgBox(YesNoQuestion, vbQuestion + vbYesNo)
End If
If answer = vbNo Then
Reset
Exit Sub
End If


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Opening notepad file then sending to back

Sorry, I just noticed that I failed to include the line to increment the
counter,
x = x + 1
that needs to be inside the For....Next loop

Steve



"Steve Yandl" wrote in message
. ..
Unless you need notepad open for some other reason besides extracting line
7 as a text string, you don't need to use it.

If OpenFile is the full path and file name of the text file you're
checking, try something like:

____________________________________

Const ForReading = 1

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTxtFile = oFSO.OpenTextFile(OpenFile, ForReading)

For x = 1 To 6
oTxtFile.ReadLine
Next

strLine = oTxtFile.ReadLine

oTxtFile.Close
_____________________________________

Now, strLine is the text from line 7 and you can check it for the date
value and you didn't need Notepad to be launched at all.


Steve



"DJ MC" wrote in message
oups.com...
I have a piece of code which opens a certain notepad file, goes to a
line of the file, reads the date which is on that line then brings up
a message box if the date is in the past, the only problem with this i
have is when its doing the check, the notepad is above excel, so if
the message box tries to display, notepad is in the way and all excel
does is flash. i need to somehow send the notepad to the background
behind excel but still be able to read from it. any help?
heres my code:

Application.ScreenUpdating = False
Shell "Notepad.exe " & OpenFile, vbNormalFocus

Set oFSO = CreateObject("Scripting.FileSystemObject")
lRow = 1
If oFSO.FileExists(OpenFile) Then
Set GFF_File = oFSO.OpenTextFile(OpenFile)

strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine
strLine = GFF_File.ReadLine

DateCheck1st = Mid(strLine, 11, 8)
DateCheck2nd = Mid(DateCheck1st, 7, 2)
DateCheck3rd = Mid(DateCheck1st, 5, 2)
DateCheck4th = Mid(DateCheck1st, 1, 4)

DateCheck = DateCheck2nd & "/" & DateCheck3rd & "/" & DateCheck4th

If DateCheck Date Then
YesNoQuestion = "Date of .GFF file is " & DateCheck & " are you
sure you want to process this file?"
answer = MsgBox(YesNoQuestion, vbQuestion + vbYesNo)
End If
If answer = vbNo Then
Reset
Exit Sub
End If





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
Sending file and opening (excel 2003) Brenda Excel Discussion (Misc queries) 4 August 2nd 11 11:14 AM
Opening & Reading file in notepad then pasting into excel using VB DJ MC Excel Programming 2 July 31st 07 10:31 AM
Opening Notepad application from Excel macro Rafael Excel Programming 5 October 9th 06 03:09 PM
Opening Notepad from Code Stan Excel Programming 3 July 16th 04 03:18 PM
opening and writing into notepad peter Excel Programming 1 August 15th 03 07:09 PM


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