SunQuest
 
           Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

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:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old April 15th, 2008, 08:29 AM
amit_jadhav9 amit_jadhav9 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 4 amit_jadhav9 Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 34 m 29 sec
Reputation Power: 0
Classic ASP/VBScript - reading word file by using word.application object

Code:
<%
Dim oDoc  
 Dim objFso  
 Dim colFiles  
 Dim curFile  
 Dim curFileName  
 Dim folderToScanExists  
 Dim folderToSaveExists  
 Dim objFolderToScan  
 'set some of the variables  
 folderToScanExists = False  
 folderToSaveExists = False  
 Const wdSaveFormat = 10 'for Filtered HTML output  
  
 '********************************************  
 'change the following to fit your system  
 Const folderToScan = "D:\amitweb"  
 Const folderToSave = "D:\ITS_RMS\images"  
 '********************************************  
  
 'Use FSO to see if the folders to read from  
 'and write to both exist.  
 'If they do, then set both flags to TRUE,  
 'and proceed with the function  

 Set objFso = CreateObject("Scripting.FileSystemObject")  
 If objFso.FolderExists(folderToScan) Then  
     folderToScanExists = True  
 Else  
     response.write "<script>alert('Folder to scan from does not exist!')</script>"  
 End If  
 If objFso.FolderExists(folderToSave) Then  
     folderToSaveExists = True  
 Else  
     response.write"<script>alert('Folder to copy to does not exist!', 48, 'File System Error');</script>"  
 End If  
  
 If (folderToScanExists And folderToSaveExists) Then  
     'get your folder to scan  
     Set objFolderToScan = objFso.GetFolder(folderToScan)  
     'put al the files under it in a collection  
     Set colFiles = objFolderToScan.Files  
     'create an instance of Word  
     Set objWord = CreateObject("Word.Application")
  
    If objWord Is Nothing Then  
         response.write"<script>alert('Couldn't start Word.', 48, 'Application Start Error');<\script>"  
     Else  
        'for each file  
         For Each curFile in colFiles  
             'only if the file is of type DOC  
             If (objFso.GetExtensionName(curFile) = "doc") Then  
                 'get the filename without extension  
                 curFileName = curFile.Name  
                 curFileName = Mid(curFileName, 1, InStrRev(curFileName, ".") - 1)  
                 'open the file inside Word  
               objWord.Documents.Open objFso.GetAbsolutePathName(curFile)  
                 'do all this in the background  
                 objWord.Visible = False  
                 'create a new document and save it as Filtered HTML  
                 Set oDoc = objWord.ActiveDocument  
                 oDoc.SaveAs folderToSave & curFileName & ".htm", wdSaveFormat  
                 oDoc.Close  
                 Set oDoc = Nothing  
             End If  
         Next  
     End If  
     'close Word  
     objWord.Quit  
     'set all objects and collections to nothing  
     Set objWord = Nothing  
     Set colFiles = Nothing  
     Set objFolderToScan = Nothing  
 End If  
  
 Set objFso = Nothing 
%>

Last edited by Shadow Wizard : April 16th, 2008 at 02:24 AM. Reason: added [Code] and [/Code] tags around code please do that yourself next.

Reply With Quote
  #2  
Old April 16th, 2008, 02:26 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information.
 
Join Date: Sep 2004
Location: Israel
Posts: 26,608 Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 6th Grade (Above 100000 Reputation Level)  Folding Points: 325618 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325618 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325618 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325618 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325618 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325618 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 4 Days 12 h 53 m 47 sec
Reputation Power: 1400
thanks for sharing the code with as, Amit.
in the future please use code tags and please put it in the Code Bank.
also, I assume you checked the code and that it works.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Classic ASP/VBScript - reading word file by using word.application object


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


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





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