it works ok !

----- Original Message ----- From: "Luc Delcoigne" <[email protected]>
To: "RBASE-L Mailing List" <[email protected]>
Sent: Monday, August 23, 2010 10:20 PM
Subject: [RBASE-L] - re: uploading .doc in rbase


Thanks again, Mike.

I'll give it a try tomorrow if I can.


Luc D.

--------------------------------------------------
From: "Mike Byerley" <[email protected]>
Sent: Monday, August 23, 2010 8:13 PM
To: "RBASE-L Mailing List" <[email protected]>
Subject: [RBASE-L] - re: uploading .doc in rbase

Ok. This will convert your *.doc to *.rtf. It does about 2 docs per second, so it looks like it might take 11 or so hours to do. I would suggest parsing the doc files into several different directories to shorten the exposure to error and having to restart. on the whole thing.

As written, the output dir is the same as the input dir, but you could mess with the Conv2DocName SUB to alter the SaveAS filename to a different directory.


'BEGIN VBSCRIPT CODE
'CommandLine = Wscript Doc2RTF.vbs [ARGS]
'ARGS = Fully Qualified Directory where *.txt Files are Located
Option Explicit

'Call the Sub
Main


Private Sub Main()
on error resume next
Dim aF()
Dim Fso
Dim oWord
Dim oDoc
Dim sPath
Dim cfile
Dim f
Dim fldr
Dim i
Const wdFormatDocument = 0
Const wdFormatDocument97 = 0
Const wdFormatText = 2
Const wdFormatDOSText = 4
Const wdFormatRTF = 6
Const wdFormatHTML = 8
Const wdFormatFilteredHTML = 10
Const wdFormatDocumentDefault = 16
Const wdFormatPDF = 17

ReDim aF(0)

Set oWord = CreateObject("Word.Application")
Set Fso = CreateObject("Scripting.FileSystemObject")

if Wscript.Arguments.Count = 0 then
 'if no command line arg - start in directory where script is executed
 sPath = Fso.GetParentFolderName(WScript.ScriptFullName)
else
 'set the Path to the Argument of the Script
 sPath = Wscript.Arguments(0)
 if lcase(sPath) = "help" then
   ShowUsage
 end if
end if

   Set fldr = Fso.GetFolder(sPath)
   if err.number <> 0 then
     msgbox "Error in Path. Quitting!"
     CallItQuits
   end if
 'Put the File List into an Array
  With Fso
 Set fldr = .GetFolder(sPath)
 If Err.Number <> 0 Then
   MsgBox "Error in Path. Quiting!"
   Set Fso = Nothing
   CallItQuits
 End If
 'Put the File List into an Array
 Set cfile = fldr.Files
 For Each f In cfile

   If LCase(.GetExtensionName(f.Name)) = "doc" Then
     If aF(UBound(aF)) = "" Then
      aF(UBound(aF)) = f.path
     Else
       ReDim Preserve aF(UBound(aF) + 1)
       aF(UBound(aF)) = f.path
     End If
   End If

 Next
 If UBound(af) = 0 And af(0) = "" Then
MsgBox "No *.doc Files were Found to Process...Quiting", VbOkOnly, "No Files Found"
   Set Fso = Nothing
   CallItQuits
 end if
 'start word and save them as *.doc files
 End With

 'start word and save them as *.doc files
 'visible -1 = true, 0 = false
 oWord.Visible = 0
 oWord.WindowState = 2 'minimized
 For i = 0 To UBound(aF)
   oWord.Documents.Open aF(i)
   Set oDoc = oWord.Documents(1)
   oDoc.SaveAs Conv2DocName(aF(i), Fso), wdFormatRTF
   oDoc.Close
 Next

 oWord.Quit
 Set FSO = Nothing
 CallItQuits
 End Sub

Private Function Conv2DocName(ByVal sIN, ByRef FsoIN)
 With FsoIN
Conv2DocName = .GetParentFolderName(sIN) & "\" & .GetBaseName(sIN) & ".RTF"
 End With
End Function

Private Sub ShowUsage()
 dim Msg
Msg = "The Script File Can Take an OPTIONAL Command Line Parameter" & VbCrLf Msg = Msg & "Which can Include the Fully Qualified Path to the Directory of the" & VbCrLf
 Msg = Msg & "Text Files (*.txt) To Be Processed." & VbCrLf & VbCrLf
Msg = Msg & "In the Absence of the OPTIONAL Command Line Parameter, the " & VbCrLf Msg = Msg & "Script will process The Directory in Which it is Started" & VbCrLf & VbCrLf
 Msg = Msg & "CommandLine = Wscript Txt2Doc.vbs [ARGS]" & VbCrLf & VbCrLf
Msg = Msg & "If the Fully Qualified Directory PathName Contains ANY SPACES" & VbCrLf Msg = Msg & "in the Name, the Argument MUST BE EnClosed In Quotes"& VbCrLf

 msgbox msg, VbOkOnly, "Command Line Usage"
 CallItQuits
End Sub

Private Sub CallItQuits()
 MsgBox "Processing Completed"
 Wscript.Quit()
End Sub

'END VBSCRIPT CODE

----- Original Message ----- From: "Luc Delcoigne" <[email protected]>
To: "RBASE-L Mailing List" <[email protected]>
Sent: Monday, August 23, 2010 11:39 AM
Subject: [RBASE-L] - re: uploading .doc in rbase


Hello Razak,

thanks for the tip.
But this seems to be a very 'manual' way to do it and quite achievable for a small number of documents.

However I have to read more than 80.000 word-documents into the database. It then seems not an option to do this manually.
Isn't there a way to automate this and speed things up ?

Luc D.

--------------------------------------------------
From: "A. Razzak Memon" <[email protected]>
Sent: Monday, August 23, 2010 5:19 PM
To: "RBASE-L Mailing List" <[email protected]>
Subject: [RBASE-L] - re: uploading .doc in rbase

At 10:34 AM 8/23/2010, Luc Delcoigne wrote:

in my Access > Rbase conversion I have come to the point that
I have to load .doc files into the varchar field of an rbase
table.

What would be the most elegant way to this, considering there
are more than 80.000 files to upload in the table....?

Luc,

Here's how I have converted/stored all .doc files into R:BASE.

01. Open the original .doc file(s) in MS Word and then save as
    .RTF to preserve the original formatting, etc.

02. Then, load these .rtf file(s) in R:BASE as VARCHAR or BLOB
    (VARBIT) data type.

    Use the appropriate data type (VARCHAR/VARBIT) accordingly.

03. Once stored in R:BASE, you may take advantage of enhanced
    Blob Editor to manage all your documents, etc.

    Tip:

    When using the enhanced R:BASE BLOB Editor, make sure to
    select [Rich Text] option/tab to manage .rtf files.

04. To print these documents in R:BASE eXtreme 9.0 reports,
    make sure to use Advanced DB Rich Text Control.

That's all there is to it!

2010 Annual R:BASE Conference Highlights include a session to
demonstrate the use of such features in R:BASE eXtreme 9.0.
http://www.rbase.com/conference/

Very Best R:egards,

Razzak.










Reply via email to