ADD HTML CODE

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top