Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old January 22nd, 2008, 05:34 PM
trx trx is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 3 trx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 58 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old January 22nd, 2008, 05:39 PM
mehere's Avatar
mehere mehere is offline
Senior Sarcasm Wizardess
Click here for more information.
 
Join Date: Feb 2005
Location: Dreamland
Posts: 12,483 mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)  Folding Points: 10976 Folding Title: Novice Folder
Time spent in forums: 4 Months 3 Weeks 3 Days 21 h 7 m 11 sec
Reputation Power: 1450
-->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

Reply With Quote
  #3  
Old January 23rd, 2008, 12:54 PM
trx trx is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 3 trx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 58 sec
Reputation Power: 0
Problem Streaming from MSWord doc

Quote:
Originally Posted by mehere
-->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.



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.

Reply With Quote
  #4  
Old January 24th, 2008, 09:52 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 675 Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Days 18 h 35 m 6 sec
Reputation Power: 308
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
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")
This is redundant. You are opening a document using the Word application. The Documents.Open method returns an object. You cannot then open that object using the FileSystemObject's OpenTextFile method.

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!


Reply With Quote
  #5  
Old January 25th, 2008, 10:40 AM
trx trx is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 3 trx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 58 sec
Reputation Power: 0
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.

Reply With Quote
  #6  
Old May 15th, 2008, 12:45 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 675 Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Days 18 h 35 m 6 sec
Reputation Power: 308
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
Quote:
Originally Posted by trx
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.
Sorry for the delayed response.

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.

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > Problems with Ms Word file using vbscript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway