+ Reply to Thread
Results 1 to 2 of 2

ADD HTML CODE

  1. #1
    Tweedy
    Guest

    ADD HTML CODE

    I'm using auto republish to update web pages from a spreadsheet. I'd like to
    insert HTML code to force browsers to refresh the data periodically when it
    is viewed. I have the code but don't know how to get it to the web page.
    Optionally does any one know of a setting that would do this.

    Thanks for all replies.
    --
    Ray Tweedale
    All-around-nice-guy

  2. #2
    Ron Coderre
    Guest

    RE: ADD HTML CODE

    I faced a similar situation some months ago when saving XL files as web
    pages. While Excel did a good job with the heavy lifting the html code still
    needed some tweaking so I formulated this procedure:

    '--beginning of code----
    Sub ReplaceTextInFile( _
    SourceFile As String, _
    srchText As String, _
    newText As String)

    Dim BullpenFile As String
    Dim tmpLine As String
    Dim intLineCtr As Long
    Dim F1 As Integer
    Dim F2 As Integer
    Dim blnContinueSrch As Boolean

    BullpenFile = "RESULT.TMP"

    If Dir(SourceFile) = "" Then
    'No source file referenced
    Exit Sub
    End If

    'If the temporary file already exists...delete it
    If Dir(BullpenFile) <> "" Then
    On Error Resume Next
    Kill BullpenFile

    On Error GoTo 0
    If Dir(BullpenFile) <> "" Then
    MsgBox BullpenFile & _
    " already open, close and delete/rename the file and try
    again.", _
    vbCritical
    Exit Sub
    End If
    End If

    F1 = FreeFile
    Open SourceFile For Input As F1

    F2 = FreeFile
    Open BullpenFile For Output As F2

    intLineCtr = 1

    application.StatusBar = "Reading data from " & BullpenFile & " ..."

    blnContinueSrch = True

    While Not EOF(F1)
    'Set the status bar message
    If intLineCtr Mod 100 = 0 Then
    application.StatusBar = "Reading line #" & intLineCtr & " in " &
    BullpenFile & " ..."
    End If

    'Read a line from the source file
    Line Input #F1, tmpLine

    If srchText <> "" Then
    If blnContinueSrch = True Then
    'perform the text replacement, if possible
    blnContinueSrch = Not ReplaceTextInString( _
    SourceString:=tmpLine, _
    SearchString:=srchText, _
    ReplaceString:=newText)
    End If
    End If

    'Write the amended line to the temporary file
    Print #F2, tmpLine

    intLineCtr = intLineCtr + 1
    Wend

    application.StatusBar = "Closing files ..."

    Close F1
    Close F2

    Kill SourceFile ' delete original file

    Name BullpenFile As SourceFile ' rename temporary file

    application.StatusBar = False
    End Sub
    '--end of code----

    I create the .htm file via code and use this code to effect the changes I
    need:

    '--beginning of code----
    ReplaceTextInFile _
    SourceFile:=strDestPath & strDestFileName, _
    srchText:="align=3dcenter x:publishsource=", _
    newText:="align=3dleft x:publishsource="
    '--end of code----

    The code may not optimized, but for my uses it works just fine.
    Is that something you can work with?

    ***********
    Regards,
    Ron

    XL2002, WinXP-Pro


    "Tweedy" wrote:

    > I'm using auto republish to update web pages from a spreadsheet. I'd like to
    > insert HTML code to force browsers to refresh the data periodically when it
    > is viewed. I have the code but don't know how to get it to the web page.
    > Optionally does any one know of a setting that would do this.
    >
    > Thanks for all replies.
    > --
    > Ray Tweedale
    > All-around-nice-guy


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1