Public InputFolder, deleteFoler, FormattedFolder As Folder Public FSO As New FileSystemObject Public RLine, WLine As TextStream Public HeadTF

, FootTF Public cow As New ADODB.Connection Public ros1 As New ADODB.Recordset Public ros2 As New ADODB.Recordset Public ros3 As New ADODB.Recordset Public totalbill, counter2, nopage Public InputFile, fstring, temstring, acno, newstring, FormatFile, Tempstr, Pres tr, vName, Orgstr, Address, VPO, PhoneNo, BillNo, Billdate, pDueDate, BillPeriod , TraficPlan, AccountNo As String Public nPage, totalNoPage, dupPage, dpage As Integer Public Inputdata Public rFor, noPinFound Public Sub Generate_OutPut_File() 'con.ConnectionString "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App .Path & "\AppTables.mdb;Persist Security Info=False" 'con.Open Set FSO = CreateObject("Scripting.FileSystemObject") Set InputFolder = FSO.GetFolder("D:\Data\") Set Allfile = InputFolder.Files Call CreateFolder Set ros1 = New ADODB.Recordset Set ros2 = New ADODB.Recordset Set ros3 = New ADODB.Recordset Open App.Path & "/Register.csv" For Output As #9 Print #9, "Accountno, PhoneNo, BillNo, BillDate, DueDate, Address, VPO, Pinc ode " ' Convert PCL into Readable PCL file For Each File In Allfile InputFile = File DoEvents Open InputFile For Input As #2 rFor = True Line_Input newstring = Replace(Inputdata, "

.

GetFolder(App.Files For Each File In GetFormatFile dupPage = 0 rFor = False FormatFile = File Open FormatFile For Input As #3 Tempstr = "" Do While True If EOF(3) = True Then Exit Do Else Line_Input End If Orgstr = Inputdata 'PAGE 1 of 1 .Path & "\Temp\" & File." & vbCrLf & "") DoEvents Open App.Name For Output As #11 Print #11.Path & "\Temp\") Set GetFormatFile = FormattedFolder. newstring Close #11 Close #2 DoEvents Next ' Actual Programming Set FormattedFolder = FSO.

"*p1946X")(1) nPage = Replace(Split(nPage.If InStr(1. "of ")(1). "*p1946XPAGE") Then nPage = Split(Inputdata. " . Inputdata.

0. "") End If If InStr(1. & Date :*p333Y*p175 0X")(1).SP1.")(0) Address = Trim(Replace(Address. "") nPage = CInt(nPage) End If If nPage = 1 Then PhoneNo = Split(Split(Inputdata. " ")(1) 'Payment Due Date :*p376Y*p1750X07/05/2012*p419Y pDueDate = Split(Split(Inputdata. "*p290Y*p175X")(0)) '*************************** 'AccountNo = AccountNo Open App.Path & "\TempFile\" & AccountNo & ".pcl" For Output .LT. "*p290Y") Then Address = Replace(Address.PW. "*p175X". "*p419Y") Then Address = Replace(Address.628. "*p290Y". Address.770.SC0.:*p591Y*p2000X")(1). "*p591Y". "Bill No. Address.78. " ")(0) Billdate = Split(Split(Inputdata. "*p376Y") Then Address = Replace(Address.SP1. "") End If If InStr(1. "") End If If InStr(1.PW. "") End If If InStr(1.%0A%0BIN. Address. "*p376Y".10.940. "*p333Y")(0) 'Bill No. "Billing Period :*p419Y* p1750X")(1). "*p591Y") Then Address = Replace(Address. "*p591Y*p1800XAccount No. "*p462Y". "*p333Y".PA60. Address.ER170. Address.10.:*p591Y*p2000X128589272*p290Y*p175X AccountNo = Trim(Split(Split(Inputdata. & Date :*p333Y*p1750X197518746 13/04/2012*p376Y BillNo = Split(Split(Inputdata. " ")) If InStr(1.940.0.940. "*p419Y")(0) 'Billing Period :*p419Y*p1750X13/02/2012 to 12/04/2012*p462Y BillPeriod = Split(Split(Inputdata.SC0. "Payment Due Date :*p376Y*p1 750X")(1). "*p290Y*p175X")(1). Address.SP1 .PA60. "*p419Y".0. "*p333Y") Then Address = Replace(Address. "*p462Y") Then Address = Replace(Address. "") End If 'For Finding Post Office VPO = "" '***************For Pincode************** If InStr(1. "-")(1)) If Pincode = "0" Or Pincode = "" Or Pincode = " " Then noPinFound = True End If End If '************Account No*************** '*p591Y*p1800XAccount No. "") End If If InStr(1." 'Starting Tag *p290Y*p175X '*p290Y '*p333Y'*p376Y'*p419Y'*p462Y'*p591Y Address = Split(Split(Inputdata.770. Address. "*p462Y")(0) 'Last Tag "%0BIN.770. "%0BIN.". "*p376Y")(0).ER280.SC0. "Phone Number(+91):*p290Y*p17 50X")(1).LT. "-") > 0 Then Pincode = Trim(Split(Address.

"Billing") > 0 Then BillNo = Split(Inputdata. "")(0) End If End If 'Account Number(8U(s1P(s17H(s8V(s0S(s0B(s16602T*p290Y*p1750X1 28589202 If InStr(1. "(+91)")(1) PhoneNo = Split(PhoneNo.Open "Insert into PCLSort values '" & pincode & "'. " ")(1). "Bill")(1) Billdate = Split(Billdate. "Account") Then AccountNo = Split(Inputdata." & B illdate & ". "X")(1). "Account")(1) AccountNo = Split(AccountNo. "Bill") < 0 And InStr(1." & Pincode AccountNo = "" PhoneNo = "" BillNo = "" Billdate = "" pDueDate = "" Address = "" VPO = "" Pincode = "" 'rs. Inpu tdata.'" & VPO & "" 'Close #3 Else counter2 = 1 Do While counter2 . "Invoice Number") And InStr(1 . " 97518846 If InStr(1.As #8 Print #8. "")(0) End If p333Y*p1750X")(1).1 <> nPage If counter2 = 1 Then 'Phone Number(+91)(8U(s1P(s17H(s8V(s0S(s0B(s16602T*p376Y*p17 50X1281202007 If InStr(1. "")(0) 'PhoneNo = Split(Split(inputdata. "*p")(2) BillNo = Split(Split(BillNo. & Date :* ")(0) 'Invoice Number(8U(s1P(s17H(s8V(s0S(s0B(s16602T*p333Y*p1750X1 Billdate = Split(Inputdata. Inputdata. "X")(1). Inputdata." & pDueDate & ". "*p")(2) PhoneNo = Split(Split(PhoneNo. "Account Num ber(8U(s1P(s17H(s8V(s0S(s0B(s16602T*p290Y*p1750X")(1). "Phone Number (+91)(8U(s1P(s17H(s8V(s0S(s0B(s16602T*p376Y*p1750X")(1). AccountNo & ". "")(0) End If If InStr(1. "Bill No. "X")(1)." & VPO & ". "*p")(2) Billdate = Split(Split(Split(Billdate. Inputdata. "Phone") Then If InStr(1." & BillNo & ". "Bill")(1) BillNo = Split(BillNo. Inputdata Close #8 Print #9. "+91") Then PhoneNo = Split(Inputdata." & Address & "." & PhoneNo & ". "*p")(2) AccountNo = Split(Split(AccountNo. "X")(1). " ")(0) 'BillNo = Split(Split(inputdata. Inputdata. Inputdata. "")(0 ) 'AccountNo = Split(Split(inputdata.

"")(0) End If If InStr(1. "Payment Due Date( 8U(s1P(s17H(s8V(s0S(s0B(s16602T*p462Y*p1750X")(1). "*p376Y") Then = Replace(Address. "*p290Y") Then = Replace(Address. "%")(0) Address = Replace(Address. "Invoice Date(8 U(s1P(s17H(s8V(s0S(s0B(s16602T*p419Y*p1750X")(1). "Payment Due Date")( 1) pDueDate = Split(pDueDate. "*p290Y*p150X") Then Address = Split(Split(Inputdata. "Payment Due Date") Then pDueDate = Split(Inputdata.. Inputdata. "") (0) End If 'pDueDate = Split(Split(inputdata. "") Address. "")(0) 'Billing Period(8U(s1P(s17H(s8V(s0S(s0B(s16602T*p505Y*p1750X1 3/02/2012 to 12/04/2012 '. " ") End If 'Address = Split(Split(inputdata. "X")(1). "*p333Y") Then = Replace(Address. "") . "Invoice Date") Then BillNo = Split(Split(Inputdata. Address End If If InStr(1. "*p333Y". Address End If If InStr(1.BillPeriod = Split(Split(inputdata. "*p290Y*p150X")(1 ). "")(0) Billdate = Split(Split(Inputdata. "")(0) End If 'Invoice Date(8U(s1P(s17H(s8V(s0S(s0B(s16602T*p419Y*p1750X13/ 04/2012 'Payment Due Date(8U(s1P(s17H(s8V(s0S(s0B(s16602T*p462Y*p1750 X07/05/2012 If InStr(1. "X")(1). "*p290Y*p175X") Then Address = Split(Split(Inputdata. "*p")(2) pDueDate = Split(Split(pDueDate. Inputdata. Address End If Address. "")(0) '*p290Y*p150X'Last %0BIN '*p290Y*p150X If InStr(1. "*p290Y*p175X")(1 ). "Billing Period") Then BillPeriod = Split(Inputdata. "Billing Period")( 1) BillPeriod = Split(BillPeriod. Inputdata. "*p290Y". "*p")(2) BillPeriod = Split(Split(BillPeriod. "*p290Y*p150X")(1). "*p376Y". "Invoice Number(8 U(s1P(s17H(s8V(s0S(s0B(s16602T*p333Y*p1750X")(1). "*p175Y". "%")(0) Address = Replace(Address. "") Address. "%")(0) If InStr(1. Inputdata. Inputdata. "*p150Y". " ") ElseIf InStr(1. "Billing Perio d(8U(s1P(s17H(s8V(s0S(s0B(s16602T*p505Y*p1750X")(1).

DueDate. Address. Address. "") End If VPO = "" If InStr(1.Path & "/CompleteRegister. Pinc ode. "Accountno." & Address & ". "*p462Y".If InStr(1.csv" For Output As #7 Print #7. "E&l4H&l1S") End If counter2 = counter2 + 1 Tempstr = Tempstr & Inputdata & vbCrLf End If Loop Open App." & PhoneNo & ". "E&l4H". "*p419Y") Then Address = Replace(Address." & Pincode AccountNo = "" PhoneNo = "" BillNo = "" Billdate = "" pDueDate = "" Address = "" VPO = "" Pincode = "" End If Loop Close #3 Next Close #9 cow. "-")(1)) If Pincode = "0" Or Pincode = "" Or Pincode = " " Then noPinFound = True End If End If Tempstr = Inputdata & vbCrLf counter2 = counter2 + 1 Else Line_Input If counter2 Mod 2 = 0 Then Inputdata = Replace(Inputdata. BillNo. PhoneNo." & VPO & ". "Haryana") > 0 Then Pincode = Trim(Split(Address. "Accountno. "*p419Y".Path & "\TempFile\" & AccountNo & ".pcl" For Output As #8 Print #8. Address.Simplex/Duplex " Open App. Tempstr Close #8 Print #9. PhoneNo. "") End If If InStr(1. "*p591Y") Then Address = Replace(Address. BillDate.Simplex/Duplex " Open App. VPO. "*p462Y") Then Address = Replace(Address.Execute "delete from GSMSorting" Open App. Address. DueDate. AccountNo & ". BillDate.Path & "/Register. "*p591Y". VPO. BillNo. "Haryana")(1)) Pincode = Trim(Split(Address. Address.Path & "/Not_Found_In_Sorting_Excel. Address.csv" For Output As #21 Print #21." & BillNo & "." & pDueDate & ".csv" For Input As #9 . "") End If If InStr(1." & B illdate & ". Pin code.Execute "delete from WLLSorting" '********************************* cn.

'" & vp1 & "'.mdb. "HFCltesT" cow. "") fl1 = ac1 & ". qr2.Open rs.")(0) oldsttr = Inputdata If olddata <> newdata Then 'qr1.'" & rs!Pincode & "'.")(6) If InStr(1.Close Close #21 Close #7 Close #9 '********************************* MsgBox "done" End Sub Public Function Make_Connection4() Set cow = CreateObject("ADODB.") Then rgstr = Trim(Replace(rgstr. ac1. ". ". 1 rc1 = rs.Open "Provider=Microsoft.".0. fl1 ac1 = Split(rgstr. "." Then Exit Do Loop cn.Jet.OLEDB.4. vp1.4. "")) If vp1 = "" Then vp1 = "Not Found" qr1 = "select * from WLLPincode where AccountNo= '" & ac1 & "'" If cn.")(0) Line_Input4 newdata = Split(Inputdata.ps" If InStr(1. "\". ".Execute qr2 Else Print #21.OLEDB.Jet. vp1.0. ". Inputdata End If .'" & fl1 & "')" rs.Path & "\BSN L. ".")(0) vp1 = Split(rgstr.Close cn.Data Source= " & App.Open "Provider=Microsoft. Inputdata Else Line Input #3.Line_Input4 Line_Input4 Set Main.Open qr1. rgstr rs.RecordCount If rc1 = 1 Then qr2 = "insert into WLLSorting values ('" & ac1 & "'.Close End If Print #7.State = 0 Then cn.Jet OLEDB:Database Password=sid@123" End Function Public Sub Line_Input() If rFor = True Then Line Input #2.Connection") 'con.Path & "\Bi ll Database\bill_printing. 1. "Admin".Data Source= " & App. vp1.Recordset oldsttr = "" Do While True 'If oldsttr = "" Then rgstr = Inputdata olddata = Split(Inputdata. rgstr End If If Inputdata = "end.mdb".rst = New ADODB. "\") Then vp1 = Replace(vp1. cn.

True FSO.CreateFolder (App.DeleteFolder App.CreateFolder (App.CreateFolder (App. strInFileContent strOutFileContent = "" j = 1 For i = 1 To Len(strInFileContent) If Asc(Mid(strInFileContent.Path & "\Temp\") = True Then FSO.Path & "\Output\") = True Then FSO.FolderExists(App. strOutFileContent Loop Close #2 Close #1 End Sub Public Sub CreateFolder() '****************************************************** If FSO.CreateFolder (App.CreateFolder (App.DeleteFolder App.Path & "\Output") End If '****************************************************** If FSO.Path & "\Output") Else FSO. i. i.Path & "\TempFile\") = True Then FSO.End Sub Private Sub ConvertFile( _ ByVal strInFileName As String. j As Long Open strInFileName For Input As #1 Open strOutFileName For Output As #2 Do Until EOF(1) Line Input #1.Path & "\Temp".FolderExists(App.FolderExists(App. 1) j = j + 1 End If Next Print #2.Path & "\TempFile") End If End Sub .Path & "\TempFile". True FSO.DeleteFolder App.Path & "\Temp") Else FSO.CreateFolder (App. True FSO.Path & "\Output". _ ByVal strOutFileName As String _ ) Dim strInFileContent As String Dim strOutFileContent As String Dim i As Long. 1)) = 10 Then strOutFileContent = strOutFileContent & vbCrLf j = j + 2 Else strOutFileContent = strOutFileContent & Mid(strInFileContent.Path & "\TempFile") Else FSO.Path & "\Temp") End If If FSO.

Sign up to vote on this title
UsefulNot useful