Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


VbScript help for PDF

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,55088
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VbScript help for PDF
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 VbScript help for PDF - 1/8/2008 2:03:22 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Hey Guys,

Right now am doing few things manualy every day,am thinking to  make this process automated.

First i will explain what i do.

every day i check three reports

Report 1: Audit ( i just ues this below query to pull the total)

select count(*) from audittb

Report 2: Recon

Select totals from recontb where number='06'

Report 3:Pdf file

i usally get thru mail,is this any way to extract pdf and get the totals and match all these totals ?


right now i just wrote the below script to pull the value from my DB

*******************************************************

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
   "Provider=SQLOLEDB;Data Source=yourserver;" & _
       "Trusted_Connection=NO;Initial Catalog=database;" & _
            "User ID=sa;Password=sa;"

objRecordSet.Open "select * from audittb", _
       objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Wscript.Echo objRecordSet.recordcount

*****************************************************
i did a search here i found some thing wrote by the great Ehvbs and Ebgreen .

Honesly i couldn't understand Ehvbs logic,so i can't move forward based on his code.

Thanks in Advance.
 
 
Post #: 1
 
 RE: VbScript help for PDF - 1/8/2008 2:06:24 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
Which post did you find? Maybe we can help you with the logic.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ashok_ganeshs)
 
 
Post #: 2
 
 RE: VbScript help for PDF - 1/8/2008 2:42:29 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Thanks ebgreen,not sure which post is that,but luckily i copied the code on the other day...here you go

Option Explicit

' ##### Globals

Const ForAppending = 8

Dim goFS  : Set goFS  = CreateObject( "Scripting.FileSystemObject" )

' ##### Choose function of current interest

WScript.Quit doMain()

' ##### main functions

Function doMain()
WScript.Echo "stefgr::doMain - (nothing) done (yet)."
doMain = 0
End Function

' ##### utility functions

' ##### Globals

+++ Const ForAppending = 8

Dim goFS  : Set goFS  = CreateObject( "Scripting.FileSystemObject" )
+++ Dim goLog : Set goLog = goFS.OpenTextFile( ".\stefgr.log", ForAppending, True )

' ##### Choose function of current interest

+++ WScript.Quit doMain2()
WScript.Quit doMain()

Sub Log( sMsg )
WScript.Echo sMsg
goLog.WriteLine Now() & " " & sMsg
End Sub

' ##### utility functions

' get open ADODB.Connection to .XLS file or die
Function getXLS( sXslFSpec )
' for more elaborate connections strings see
' http://www.connectionstrings.com
Dim oCN : Set oCN = CreateObject( "ADODB.Connection" )
Dim sCS : sCS     = Join( Array( _
                 "Provider=Microsoft.Jet.OLEDB.4.0"    _
               , "Data Source=" & goFS.GetAbsolutePathName( sXslFSpec )  _
               , "Extended Properties=""Excel 8.0;HDR=YES;MAXSCANROWS=1""" _
                               ), ";" )

' for more elaborate operations see ado<NN>.chm
oCN.Open sCS
Set getXLS = oCN
End Function

' get open ADODB.Connection (TEXT) to current directory or die
Function getTXT()
Dim oCN : Set oCN = CreateObject( "ADODB.Connection" )
Dim sCS : sCS     = Join( Array(                                 _
                 "Provider=MSDASQL.1"                            _
               , "Driver={Microsoft Text Driver (*.txt; *.csv)}" _
               , "DBQ=" & goFS.GetAbsolutePathName( ".\" )       _
                               ), ";" )
oCN.Open sCS
Set getTXT = oCN
End Function

' poor man's grid display

Function doMain2()
Dim cnMSS : Set cnMSS = getXLS( ".\total_abs_list.xls" )
Log "connect to xls."
Dim cnTXT : Set cnTXT = getTXT()
Log "connect to txt."
cnTXT.Close
Log "xls closed."
cnMSS.Close
Log "txt closed."
WScript.Echo "stefgr::doMain2 - open/close connections."
doMain2 = 0
End Function

C:\wis\_vbs\0506\dev\forum\stefgr
cscript stefgr.vbs
connect to xls.
connect to txt.
xls closed.
txt closed.
stefgr::doMain2 - open/close connections.

C:\wis\_vbs\0506\dev\forum\stefgr
type stefgr.log
19.12.2007 14:39:53 connect to xls.
19.12.2007 14:39:53 connect to txt.
19.12.2007 14:39:53 xls closed.
19.12.2007 14:39:53 txt closed.

Option Explicit

' ##### Globals

Const ForAppending = 8

Dim goFS  : Set goFS  = CreateObject( "Scripting.FileSystemObject" )
Dim goLog : Set goLog = goFS.OpenTextFile( ".\stefgr.log", ForAppending, True )

' ##### Choose function of current interest

WScript.Quit frsLook()
WScript.Quit doMain2()
WScript.Quit doMain()

' ##### main functions

Function frsLook()
Dim cnMSS : Set cnMSS = getXLS( ".\total_abs_list.xls" )
Dim sSQL  : sSQL      = "SELECT * FROM [Sheet1$]"
Dim oRS   : Set oRS   = cnMSS.Execute( sSQL )
showRS oRS
oRS.Close
cnMSS.Close
WScript.Echo "stefgr::frsLook - access sheet as table."
frsLook = 0
End Function

Function doMain2()
Dim cnMSS : Set cnMSS = getXLS( ".\total_abs_list.xls" )
Log "connect to xls."
Dim cnTXT : Set cnTXT = getTXT()
Log "connect to txt."
cnTXT.Close
Log "xls closed."
cnMSS.Close
Log "txt closed."
WScript.Echo "stefgr::doMain2 - open/close connections."
doMain2 = 0
End Function

Function doMain()
WScript.Echo "stefgr::doMain - (nothing) done (yet)."
doMain = 0
End Function

' ##### utility functions

' get open ADODB.Connection to .XLS file or die
Function getXLS( sXslFSpec )
' for more elaborate connections strings see
' http://www.connectionstrings.com
Dim oCN : Set oCN = CreateObject( "ADODB.Connection" )
Dim sCS : sCS     = Join( Array( _
                 "Provider=Microsoft.Jet.OLEDB.4.0"    _
               , "Data Source=" & goFS.GetAbsolutePathName( sXslFSpec )  _
               , "Extended Properties=""Excel 8.0;HDR=YES;MAXSCANROWS=1""" _
                               ), ";" )

' for more elaborate operations see ado<NN>.chm
oCN.Open sCS
Set getXLS = oCN
End Function

' get open ADODB.Connection (TEXT) to current directory or die
Function getTXT()
Dim oCN : Set oCN = CreateObject( "ADODB.Connection" )
Dim sCS : sCS     = Join( Array(                                 _
                 "Provider=MSDASQL.1"                            _
               , "Driver={Microsoft Text Driver (*.txt; *.csv)}" _
               , "DBQ=" & goFS.GetAbsolutePathName( ".\" )       _
                               ), ";" )
oCN.Open sCS
Set getTXT = oCN
End Function

' poor man's grid display
Sub showRS( oRS )
Const adClipString = 2 ' to keep ADO happy
Dim sHead : sHead = ""
Dim oFld
For Each oFld In oRS.Fields
    sHead = sHead & vbTab & oFld.Name
Next
' to cope with empty recordsets
Dim sData
If oRS.EOF Then sData = "no data" & vbCrLf Else sData = oRS.GetString( adClipString, , vbTab, vbCrLf, "NULL" )
WScript.Echo Join( Array( _
            String( 70, "=" ) _
          , vbCrLf _
          , oRS.Source _
          , vbCrLf _
          , Mid( sHead, 2 ) _
          , vbCrLf _
          , String( 70, "-" ) _
          , vbCrLf _
          , sData _
          , String( 70, "=" ) _
                        ), "" )
End Sub

' reduce whitespace in SQL (dangerous!)
Function cleanSQL( sSQL )
Dim oRE : Set oRE = New RegExp
oRE.Global  = True
oRE.Pattern = "\s+"
cleanSQL    = oRE.Replace( sSQL, " " )
End Function

' poor man's Log4VBScript
Sub Log( sMsg )
WScript.Echo sMsg
goLog.WriteLine Now() & " " & sMsg
End Sub


C:\wis\_vbs\0506\dev\forum\stefgr
cscript stefgr.vbs
======================================================================
SELECT * FROM [Sheet1$]
F1      Surname Name    Course  Absences' Limit Total Absences  Excused Absences        Unexcused Absences      3rd Phone
----------------------------------------------------------------------
1       APOSTOLIDIS     FOIVOS  CIS-787174A - DATABASE SYSTEMS  6       10      NULL    10      6945757419
2       BINTELAS        ELEFTHERIOS     COMM-782004A - COMMUNICATIONS ANALYSIS  6       15      NULL    15      6932445984
NULL    NULL    NULL    COMM-782154A - INFORMATION GATHERING & REPORTING        6       7       NULL    7       Null
NULL    NULL    NULL    COMM-782154A - INFORMATION GATHERING & REPORTING        6       7       NULL    7       Null
3       APOSTOLIDIS     FOIVOS  CIS-787174A - DATABASE SYSTEMS  6       10      NULL    10      6945757419
NULL    NULL    NULL    IUKB4 - GLOBAL MARKETING        9       10      NULL    10      Null
NULL    RASHKOVA        MELINA  IUKB20 - ACCOUNTING     9       11      NULL    11      6981752219
[...]
NULL    NULL    NULL    H-C15 - VISUAL PROGRAMMING      9       14      NULL    14      Null
NULL    NULL    NULL    H-C28 - NETWORKING TECHNOLOGY   9       13      NULL    13      Null
NULL    TZANES  KALLIOPI        H-C14 - DATA ANALYSIS & DATABASE DESIGN 9       21      NULL    21  6932488676
NULL    NULL    NULL    H-C15 - VISUAL PROGRAMMING      9       14      NULL    14      Null
NULL    NULL    NULL    H-C28 - NETWORKING TECHNOLOGY   9       18      NULL    18      Null
NULL    GEROYLANOY      E?ATERINI       APC308 - FINANCIAL MANAGEMENT   9       12      NULL    12  6937084124
NULL    KUMANI  RENALD  SIM366 - STRATEGIC MANAGEMENT   9       10      NULL    10      6947228118
NULL    XELIOTI KATERINA        APC308 - FINANCIAL MANAGEMENT   9       15      NULL    15      Null
NULL    NULL    NULL    SIM366 - STRATEGIC MANAGEMENT   9       12      NULL    12      Null
NULL    S????? 1        NULL    NULL    NULL    NULL    NULL    NULL    Null
======================================================================
stefgr::frsLook - access sheet as table.

C:\wis\_vbs\0506\dev\forum\stefgr
cscript stefgr.vbs
======================================================================
SELECT * FROM [Sheet1$]
F1      Surname FrsName Course  AbsLimit        AbsTotal        AbsExcused      AbsNotExcused   Phone3
----------------------------------------------------------------------
1       APOSTOLIDIS     FOIVOS  CIS-787174A - DATABASE SYSTEMS  6       10      NULL    10      6945757419
2       BINTELAS        ELEFTHERIOS     COMM-782004A - COMMUNICATIONS ANALYSIS  6       15      NULL    15      6932445984
NULL    NULL    NULL    COMM-782154A - INFORMATION GATHERING & REPORTING        6       7       NULL    7       Null
NULL    NULL    NULL    COMM-782154A - INFORMATION GATHERING & REPORTING        6       7       NULL    7       Null
[...]
NULL    GEROYLANOY      E?ATERINI       APC308 - FINANCIAL MANAGEMENT   9       12      NULL    12  6937084124
NULL    KUMANI  RENALD  SIM366 - STRATEGIC MANAGEMENT   9       10      NULL    10      6947228118
NULL    XELIOTI KATERINA        APC308 - FINANCIAL MANAGEMENT   9       15      NULL    15      Null
NULL    NULL    NULL    SIM366 - STRATEGIC MANAGEMENT   9       12      NULL    12      Null
======================================================================
stefgr::frsLook - access sheet as table.


Function showPC()
Dim cnMSS : Set cnMSS = getXLS( ".\total_abs_list.xls" )
Dim sSQL, oRS

sSQL    = Join( Array( _
            "SELECT DISTINCT Surname, FrsName, Phone3" _
          , "FROM [Sheet1$]" _
          , "WHERE Surname IS NOT NULL" _
          , "ORDER BY Surname DESC" _
                     ), " " )
Set oRS = cnMSS.Execute( sSQL )
showRS oRS
oRS.Close

sSQL    = Join( Array( _
            "SELECT DISTINCT Course" _
          , "FROM [Sheet1$]" _
          , "WHERE Course IS NOT NULL" _
          , "ORDER BY Course" _
                     ), " " )
Set oRS = cnMSS.Execute( sSQL )
showRS oRS
oRS.Close

cnMSS.Close
WScript.Echo "stefgr::showPC - show users/courses."
showPC = 0
End Function


Function showPCHTML()
Dim cnMSS : Set cnMSS = getXLS( ".\total_abs_list.xls" )
Dim sSQL, oRS

sSQL    = Join( Array( _
            "SELECT DISTINCT SurName, FrsName, Phone3" _
          , "FROM [Sheet1$]" _
          , "WHERE Surname IS NOT NULL" _
          , "ORDER BY Surname DESC" _
                     ), " " )
Set oRS = cnMSS.Execute( sSQL )
showRSHTML "persons.html", oRS
oRS.Close

sSQL    = Join( Array( _
            "SELECT DISTINCT Trim( Course ) AS Course" _
          , "FROM [Sheet1$]" _
          , "WHERE Course IS NOT NULL AND '' <> Trim( Course )" _
          , "ORDER BY Trim( Course )" _
                     ), " " )
Set oRS = cnMSS.Execute( sSQL )
' showRSHTML "courses.html", oRS
oRS.Close

cnMSS.Close
WScript.Echo "stefgr::showPCHTML - show persons/courses using HTML."
showPCHTML = 0
End Function


' poor man's HTML display
Sub showRSHTML( sFiNa, oRS )
Const adClipString = 2 ' to keep ADO happy
Dim sName  : sName  = goFS.GetFileName( sFiNa )
Dim sFSpec : sFSpec = goFS.GetAbsolutePathName( sFiNa )
Dim sHead  : sHead  = ""
Dim sHTML  : sHTML  = Join( Array( _
          "<html>" _
        , " <head>" _
        , "  <title>" & sName & "</title>" _
        , " </head>" _
        , " <body>" _
        , "  <table border = '1' summary = '" & sName & "'>" _
        , "   <tr>" _
        , "    @Head@" _
        , "   </tr>" _
        , "   @Data@" _
        , "  </table>" _
        , " </body>" _
        , "</html>" _
                               ), vbCrLf )
Dim oFld
For Each oFld In oRS.Fields
    sHead = sHead & "<th>" & oFld.Name & "</th>"
Next
' to cope with empty recordsets
Dim sData
If oRS.EOF Then
   sData = "<tr><td>no data</td></tr>"
Else
   sData =  "<tr><td>" _
           & oRS.GetString( adClipString, , "</td><td>", "</td></tr>" & vbCrLf & "   <tr><td>", "NULL" ) _
           & "     </td></tr>"
End If
sHTML = Replace( sHTML, "@Head@", sHead   )
sHTML = Replace( sHTML, "@Data@", sData   )
sHTML = Replace( sHTML, "&"     , "&amp;" ) ' more work to do!

goFS.CreateTextFile( sFSpec, True ).Write sHTML

End Sub

  sSQL    = Join( Array( _
            "SELECT FrsName" _
          , "FROM [Sheet1$]" _
          , "WHERE FrsName IS NOT NULL" _
                     ), " " )
Set oRS = cnMSS.Execute( sSQL )
' showRSHTML "persons.html", oRS
Do Until oRS.EOF
   WScript.Echo oRS( "FrsName" ).Value
   goLog.WriteLine oRS( "FrsName" ).Value
   oRS.MoveNext
Loop
oRS.Close

Function SimpleQueries()
Dim cnMSS : Set cnMSS = getXLS( ".\total_abs_list.xls" )
Dim sSQL, oRS

sSQL    = Join( Array( _
            "SELECT SurName, FrsName" _
          , "FROM [Sheet1$]" _
          , "WHERE  Surname IS NOT NULL AND Phone3 IS NULL" _
          , "ORDER BY Surname, FrsName" _
                     ), " " )
Set oRS = cnMSS.Execute( sSQL )
showRS oRS
oRS.Close

sSQL    = Join( Array( _
            "SELECT SurName" _
          , "FROM [Sheet1$]" _
          , "WHERE  Surname IS NOT NULL AND FrsName IS NULL" _
          
          , "ORDER BY Surname" _
                     ), " " )
Set oRS = cnMSS.Execute( sSQL )
showRS oRS
oRS.Close

sSQL    = Join( Array( _
            "SELECT SurName, FrsName" _
          , "FROM [Sheet1$]" _
          , "WHERE  Surname IS NOT NULL AND 'A' = Left( FrsName, 1 )" _
          , "ORDER BY FrsName" _
                     ), " " )
Set oRS = cnMSS.Execute( sSQL )
showRS oRS
oRS.Close

sSQL    = Join( Array( _
            "SELECT SurName, FrsName" _
          , "FROM [Sheet1$]" _
          , "WHERE  Surname IS NOT NULL AND Left( FrsName, 1 ) IN ( 'A', 'E', 'O' )" _
          , "ORDER BY FrsName" _
                     ), " " )
Set oRS = cnMSS.Execute( sSQL )
showRS oRS
oRS.Close

Dim aNumbers : aNumbers = Array( "AbsLimit", "AbsTotal", "AbsExcused", "AbsNotExcused" )
Dim aFuncs   : aFuncs   = Array( "COUNT", "MIN", "MAX", "AVG" )
Dim sFld, sFunc, sTmp
sSQL = "SELECT @F@( @C@ ) FROM [Sheet1$] WHERE @C@ IS NOT NULL"
For Each sFld In aNumbers
    For Each sFunc In aFuncs
        sTmp    = Replace( sSQL, "@F@", sFunc )
        sTmp    = Replace( sTmp, "@C@", sFld  )
'         WScript.Echo sTmp
        Set oRS = cnMSS.Execute( sTmp )
        WScript.Echo sFld, sFunc, oRS.Fields( 0 ).Value
        oRS.Close
    Next
    WScript.Echo
Next

sSQL    = Join( Array( _
            "SELECT Surname, Phone3, AbsTotal, AbsNotExcused" _
          , "FROM [Sheet1$]" _
          , "WHERE AbsTotal<> AbsNotExcused" _
                     ), " " )
Set oRS = cnMSS.Execute( sSQL )
showRS oRS
oRS.Close

cnMSS.Close
WScript.Echo "stefgr::SimpleQueries - show persons/courses using HTML."
SimpleQueries = 0
End Function

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: VbScript help for PDF - 1/8/2008 2:51:38 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
Wow. that is one of ehvbs' larger ones. Perhaps for the time being we should forget about altering his code and simply use it to pick and choose the parts that you need. For instance, it looks like your code populates a recordset then you move to the beginning of the recordset but you don't do anything with the data in the recordset. Search the forum for .MoveNext. When you find that you will have found an example of doing something with every record in a recordset.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ashok_ganeshs)
 
 
Post #: 4
 
 RE: VbScript help for PDF - 1/8/2008 3:05:00 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Thanks ebgreen,The search is not returning anything for "MoveNext",probably i will try with sql and dig more in to it.

Thanks again
Ashok

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: VbScript help for PDF - 1/8/2008 3:06:58 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
When I searched for MoveNext, I found this thread:

http://www.visualbasicscript.com/m_50245/mpage_1/key_MoveNext/tm.htm#50252

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ashok_ganeshs)
 
 
Post #: 6
 
 RE: VbScript help for PDF - 1/8/2008 3:19:18 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Thanks Ebgreen,I don't think so i need Move First,so i removed from the code.

Bcoz i just need the total counts,

anyway recordset.recrodcount will retun the record count.

I just executed that script, it returns the total count.

(in reply to ebgreen)
 
 
Post #: 7
 
 RE: VbScript help for PDF - 1/8/2008 3:20:15 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
Cool, so what is the next task that you need the script to do?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ashok_ganeshs)
 
 
Post #: 8
 
 RE: VbScript help for PDF - 1/8/2008 3:27:05 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
am not sure ,how to read the Pdf File thru vbscript,like how we use to read a txt file.

Thanks

(in reply to ebgreen)
 
 
Post #: 9
 
 RE: VbScript help for PDF - 1/8/2008 3:33:01 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
To be honest with you I have never found a good way to look at the contents of a pdf from vbscript. I'll look into it some more.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ashok_ganeshs)
 
 
Post #: 10
 
 RE: VbScript help for PDF - 1/8/2008 3:37:01 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
even i tried one full day in google,nothing helpful to me,that's why i just start a new post here,bcoz my earlier problem solved by you guys.

if you find any thing in the future pl let me know,in the mean time i probably convert PDF in to TXT then use my script to read it.

Thanks
Ashok

(in reply to ebgreen)
 
 
Post #: 11
 
 RE: VbScript help for PDF - 1/8/2008 3:38:40 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
Whatever solution I found would probably involve doing exactly that.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ashok_ganeshs)
 
 
Post #: 12
 
 RE: VbScript help for PDF - 1/10/2008 6:17:15 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
A'ight finally i changed the legacy system to generate text file rather than pdf.

Now i got little bit confused to proceed.

I just wanna get the total (Pl see the attachment for the sample) on Line number 8 and the colmn number 46 to 56.I was thinking to proceed with Regular Expression but i do have more than one "total" is occouring on that file.

Some one will feed me some logic how to proceed.

Thanks
Ashok

Attachment (1)

(in reply to ebgreen)
 
 
Post #: 13
 
 RE: VbScript help for PDF - 1/10/2008 6:35:05 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
am trying with these code below

Dim contents,col,linenumber
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\test\test.txt")
If objFile.Size > 0 Then
   Set objReadFile = objFSO.OpenTextFile("C:\test\test.txt", 1)
   Do While objReadFile.AtEndOfStream <> True
    contents= objReadFile.read(8)
    col =objReadFile.Column -46
    linenumber= objReadFile.Line
   Loop
   'strContents = objReadFile.ReadAll
   'Wscript.Echo strContents
   WScript.Echo "The last character in line " & lineumber & " is '" & contents & "' and its column number is '" & col & "'."
   objReadFile.Close
Else
   Wscript.Echo "The file is empty."
End If

(in reply to ashok_ganeshs)
 
 
Post #: 14
 
 RE: VbScript help for PDF - 1/10/2008 7:36:30 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
as of now

I just wrote the simple one

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\test\test.txt", ForReading)

For i = 1 to 9
   objTextFile.ReadLine
Next
strLine = objTextFile.ReadLine
strcolum = objTextFile.Column -1
Wscript.Echo strLine
wscript.Echo strcolumn
WScript.Echo objTextFile.Read(60)
objTextFile.Close

but still thinkin to get only specific column value.

thanks
Ashok

(in reply to ashok_ganeshs)
 
 
Post #: 15
 
 RE: VbScript help for PDF - 1/10/2008 7:36:45 AM   
  ehvbs

 

Posts: 2173
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Ashok,

you should read about .Read in the VBScript Docs. The param specifies the number
of characters to read.

[Obviously you did that while I wrote this; good for you!]

If you want to

  read 9 chars from line 8, col 46 in text.txt

use something like this:

Option Explicit

Dim objFSO  : Set objFSO  = CreateObject( "Scripting.FileSystemObject" )
Dim objFile : Set objFile = objFSO.GetFile( "test.txt" )
If objFile.Size > 0 Then
Dim aLines : aLines = Split( objFile.OpenAsTextStream().ReadAll, vbCrLf )
WScript.Echo "9 chars from line 8, col 46 in text.txt: |" & Mid( aLines( 7 ), 46, 9 ) & "|"
Else
Wscript.Echo "The file is empty."
End If

Good luck!

ehvbs

< Message edited by ehvbs -- 1/10/2008 7:38:36 AM >

(in reply to ashok_ganeshs)
 
 
Post #: 16
 
 RE: VbScript help for PDF - 1/10/2008 12:47:26 PM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Hi Ehvbs,

Good to see you.

Even i was thinking to get only that specific column,so thought abt to start tommorow,but you already sent the logic,thanks a lot.

any way i will try some different method,then post it back.(its really simple for you guys,but am not in touch with Script for quite long,facing some difficulties)

Thanks Again
Ashok

(in reply to ehvbs)
 
 
Post #: 17
 
 RE: VbScript help for PDF - 1/10/2008 8:05:41 PM   
  ehvbs

 

Posts: 2173
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Ashok,

you are welcome. Thanks for the feedback.

Eagerly waiting for your different method(s)

ehvbs

(in reply to ashok_ganeshs)
 
 
Post #: 18
 
 RE: VbScript help for PDF - 1/28/2008 3:21:05 AM   
  ashok_ganeshs

 

Posts: 92
Score: 0
Joined: 12/5/2006
Status: offline
Sorry for the late reply.

Whenever i get time i use to work on this script ,eventually finished .

here you go.

The other method i said earlier like this

The out put : Total (space) 1,11,106
i was thinking to use array like this ,but ehvbs way is more efficient so i used his part to get that particular column value.

MMISARRAY = Split(Count, "vbcrlf",4, VBTextCompare)
MMIScountCheck=MMISARRAY(0)& MMISARRAY(1)& MMISARRAY(2)


Here you go for  my complete script.


'==========================================================================
'Option Explicit

Dim Prod1_EligRecon
Dim Prod1_EligAudit
Dim Prod2_EligRecon
Dim Prod2_EligAudit
Dim Test1_EligRecon
Dim Test1_EligAudit
Dim Test2_EligRecon
Dim Test2_EligAudit
Dim MMIScount
Dim MMIScountCheck
Dim MMISARRAY
Dim EmdeonCount
Dim result
Dim FinalCheck
Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
Set objRecordSet1=CreateObject("Adodb.recordset")
Dim objFSO  : Set objFSO  = CreateObject( "Scripting.FileSystemObject" )
Dim objFSO1 : Set objFSO1 = CreateObject( "Scripting.FileSystemObject" )
Dim objFile : Set objFile = objFSO.GetFile( "c:\test\test.txt" )
Dim objFile1 : Set objFile1