|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Problems with Ms Word file using vbscript
I have tried this but it still does not work. please help. here is what I have ...
Code:
Set objFSO = CreateObject("Word.Application")
objFSO.Visible = True
Set objFile1 = objFSO.Documents.Open("C:\Documents and Settings\trx\Desktop\1 Intro.doc")
Set objFile2 = objFSO.OpenTextFile(ObjFile1, ForReading)
Set outfile = objFSO.CreateTextFile("C:\Documents and Settings\trx\Desktop\writeToWordList.doc")
Set objRegEx = CreateObject("VBScript.RegExp") 'create an instance of the VBScript.RegExp object
objRegEx.Global = True ' set to true so it continues to find all matches rather than find one match and stop
objRegEx.Pattern = "\bSlide...\b" 'regular expression pattern to find in text file
Do Until objFile.AtendOfStream
Dim strSearchString, Matches, strMatch
strSearchString = objFile.ReadLine
Set Matches = objRegEx.Execute(strSearchString)
If Matches.Count > 0 Then
For Each strMatch in Matches
Dim title
title = Mid(strSearchString, 12)
outfile.writeline(title)
'go to Daisy on IE
Next
else
Dim temp
temp = Left(strSearchString, 8)
if StrComp(temp, endTag, 1) = 0 then
MsgBox temp
else
outfile.writeline(strSearchString)
end If
End If
Loop
objFile.Close
Last edited by mehere : January 22nd, 2008 at 05:38 PM. Reason: added code tags ... please use [code][/code] tags in the future. |
|
#2
|
||||
|
||||
|
-->Split from thread
Please do not highjack other threads. Now ... telling us it doesn't work, doesn't help us help you. Please inform us what you're trying to do, what error messages you are getting, which line the error message points to.
__________________
Come JOIN the party!!! Quote of the Month: Trouble: Luck can't last a lifetime unless you die young. Questions to Ponder: Do cemetery workers prefer the graveyard shift? iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm") copyright© 2008 sbenj69 |
|
#3
|
|||
|
|||
|
Problem Streaming from MSWord doc
Quote:
hello, Well I am trying to read from a MS word doc line for line, but from what I have in my code it only works for plain text, and the error it gives me that (ObjFile.AtendofStream) objFile does not have that method or property. Any help would be fully appreciated. |
|
#4
|
||||
|
||||
|
Code:
Set objFSO = CreateObject("Word.Application")
objFSO.Visible = True
Set objFile1 = objFSO.Documents.Open("C:\Documents and Settings\trx\Desktop\1 Intro.doc")
Set objFile2 = objFSO.OpenTextFile(ObjFile1, ForReading)
Set outfile = objFSO.CreateTextFile("C:\Documents and Settings\trx\Desktop\writeToWordList.doc")
Aside from that, the OpenTextFile method requires a string (file path) as its first parameter. Your best bet would be to select all of the contents once you open the file and then copy it to a blank text document where you can paste it as plain text.
__________________
Click the image if at any point you don't like my decision.Scripting problems? Windows questions? Ask the Windows Guru! |
|
#5
|
|||
|
|||
|
I already did that, but my main question is that, is there a way that you can read line from line from a MSWord doc, if yes, any tips on how to? Help would be fully appreciated. Thanks man.
|
|
#6
|
||||
|
||||
|
Quote:
Reading line by line using the Word automation object is a pain in the neck to say the least. The easiest method is to use Word to open and save the document in plain text. Then simply delete the extra file when you're finished. |
![]() |
| Viewing: ASP Free Forums > System Administration > Windows Scripting > Problems with Ms Word file using vbscript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
![]() |
|