RE: ADD HTML CODE
- From: "Ron Coderre" <ronSKIPTHIScoderre@xxxxxxxxxxx>
- Date: Sat, 14 Jan 2006 14:08:01 -0800
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
.
- Prev by Date: Re: difficult for me, easy for others .. !?
- Next by Date: Re: Golf handicap using 4 of last 5 scores
- Previous by thread: Formatting a single cell
- Next by thread: merging data
- Index(es):
Relevant Pages
|