HTML files management with vba

'these were for updating more than 300 html files just with one code

'their objective was to make html content uniform 

Private Sub cmdopnnotepad_Click()

Dim dTaskID As Double, path As String, file As String

path = "C:\WINDOWS\notepad.exe"

Dim filevalname As String

Dim filenumopn As String

    For xtc = 1 To 1

    simxtc = xtc + 1

    filenumopn = "00" & simxtc & ".html"

    filevalname = "C:\models\" & filenumopn

    Me!txtfilename.Value = filenumopn

    file = filevalname

    dTaskID = Shell(path + " " + file, vbNormalFocus)

    'MsgBox ("Text loaded")

    

    textsd As Document

    

    textsd = file

    '****************replace************************

'REPLACE ALL kodu asagida :

txtFind = "sokolag"

txtReplace = "yarrakkurek"

SandR

'---------------------CODE

 'Private Sub makenormallistIPlist()

       txtInputIPlist.Text = ""

       Dim dTelip As Double

       Dim stext As String

       Dim sFile As String


       For Each sFile In ofdIPlist.FileNames

         Dim slijn As String

         FileOpen(1, sFile, OpenMode.Input)

           Do Until EOF(1)

               slijn = LineInput(1)

                If slijn = "string 1" Then

               stext = stext & "altered text" & vbCrLf

               Else: stext = stext & slijn & vbCrLf

               End If

           Loop

           FileClose (1)

       Next

       txtInputIPlist.Text = txtInputIPlist.Text & stext

  ' End Sub


    Next xtc

End


End Sub


'------------------------


Private Sub cmdhtmlfilechange_Click()

Dim Counter As Integer

    Dim Filename As String

    Dim FullLine As String

    

    For Counter = 0 To 435

        Filename = "C:\models\" & Format(Counter, "000") & ".html"

        'rename original file as *.old

        Name Filename As "C:\models\" & Format(Counter, "000") & "old.html"

        

        Open "C:\models\" & Format(Counter, "000") & "old.html" For Input As #1

        Open Filename For Output As #2

        

 '       Do While Not EOF(1)

 '           Line Input #1, FullLine

 '           Print #2, Replace(FullLine, "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 >", "")

 '       Loop

        

        Do While Not EOF(1)

            Line Input #1, FullLine

            'FullLine = Replace(FullLine, Chr$(34) & "</A>","& Chr$(34) & ">Click this Link</A>")

            'FullLine = Replace(FullLine, "Previous</A>", " Previous </A>")

            'FullLine = Replace(FullLine, vbNewLine & vbNewLine & vbNewLine & vbNewLine, "")     ' replace line feed

            'FullLine = Replace(FullLine, "<td>ID", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">ID")

            'FullLine = Replace(FullLine, "<td>email business", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">email business")

            'FullLine = Replace(FullLine, "<td>email2 business", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">email2 business")

            ''FullLine = Replace(FullLine, "<td>Bustsize/Stats", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">Stats")

            'FullLine = Replace(FullLine, "<td>Eyes", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">Eyes")

            'FullLine = Replace(FullLine, "<td>Hair", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">Hair")

            'FullLine = Replace(FullLine, "<td>Cup", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">Cup")

            'FullLine = Replace(FullLine, "<td>Official Website", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">Official Website")

            'FullLine = Replace(FullLine, "<td>Myspace", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">Myspace")

            ''FullLine = Replace(FullLine, "<td>yahoogroup", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">yahoogroup")

            'FullLine = Replace(FullLine, "<td>website 1", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">website 1")

            'FullLine = Replace(FullLine, "<td>website 2", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">website 2")

            'FullLine = Replace(FullLine, "<td>website 5", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">website 3")

            'FullLine = Replace(FullLine, "<td>website 6", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">website 4")

            'FullLine = Replace(FullLine, "<td>website 7", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">website 5")

            'FullLine = Replace(FullLine, "<td>website 8", "<td rowspan=" & Chr$(34) & "2" & Chr$(34) & ">website 6")

            'FullLine = Replace(FullLine, "/TABLE></BODY>", "/TABLE><table><tr><td><img src=" & Chr$(34) & Chr$(34) & "></td><td><img src=" & Chr$(34) & Chr$(34) & "></td><td><img src=" & Chr$(34) & Chr$(34) & "></td></tr><tr><td><img src=" & Chr$(34) & Chr$(34) & "></td><td><img src=" & Chr$(34) & Chr$(34) & "></td><td><img src=" & Chr$(34) & Chr$(34) & "></td></tr></table></BODY>")

            'FullLine = Replace(FullLine, "<img src=", "<img width=300 src=")

            'FullLine = Replace(FullLine, "Cup</FONT>", "Cup</FONT></td></tr><tr><td>..")

            'FullLine = Replace(FullLine, "Hair</FONT>", "Hair</FONT></td></tr><tr><td>..")

            'FullLine = Replace(FullLine, "Eyes</FONT>", "Eyes</FONT></td></tr><tr><td>..")

            FullLine = Replace(FullLine, "img width=300", "img width=140")

            'FullLine = Replace(FullLine, "", "")

            'FullLine = Replace(FullLine, "", "")

           Print #2, FullLine

        Loop


        

        Close #1

        Close #2

            

    Next Counter


End Sub

'------------------------

Private Sub cmd_kill_Click()

    Dim Filename As String

For Counter = 0 To 435

Kill "C:\models\" & Format(Counter, "000") & "old.html"

    Next Counter


End Sub


Comments

Popular posts from this blog

use of variable

VBA - sorting data