Open and edit HTM from PPT VBA macro....

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

Guest

I have a VBA macro that save my currently slide as a web page...

After I save the slide as a HTM page, I want to Open the HTM page and
programatically edit it... specifically I want to search for a string of
text, then replace it and save changes.

I'm drawing a blank on how to open and edit a (HTM) from VBA... what's the
easiest way to go about doing this?

Thanks!
 
I have a VBA macro that save my currently slide as a web page...

After I save the slide as a HTM page, I want to Open the HTM page and
programatically edit it... specifically I want to search for a string of
text, then replace it and save changes.

I'm drawing a blank on how to open and edit a (HTM) from VBA... what's the
easiest way to go about doing this?

HTM is just plain text. Treat it as you would any text file.
For example, you could read the file into a string variable and do whatever you
need to do to it, then write it back to file.
 
Thanks... for the benefit of others, here's what I did:

'Open and edit a PPT slide saved as HTM
' Change background color of slide to NAVY blue...
Dim InFile As Integer
Dim OutFile As Integer
InFile = FreeFile
'name and sName defined above...
Open ActivePresentation.Path & "\" & name & "_files\slide" &
Format(sName, "0000") _
& ".htm" For Input As InFile
OutFile = FreeFile
Open ActivePresentation.Path & "\" & name & "_files\slide" &
Format(sName, "0000") _
& ".htm_mod" For Append As OutFile
InputString = ""
While Not EOF(InFile)
Line Input #InFile, InputString 'read a line from the textfile
If InStr(InputString, "background-color:white'") > 0 Then
InputString = Replace(InputString,
"background-color:white'", _
"background-color:#103C6F'", 1, , vbTextCompare)
End If
Print #OutFile, InputString
Wend
Close #InFile
Close #OutFile
Name ActivePresentation.Path & "\" & name & "_files\slide" &
Format(sName, "0000") & ".htm" As ActivePresentation.Path & "\" & name &
"_files\slide" & Format(sName, "0000") & "_ORIG.htm"
Name ActivePresentation.Path & "\" & name & "_files\slide" &
Format(sName, "0000") & ".htm_mod" As ActivePresentation.Path & "\" & name &
"_files\slide" & Format(sName, "0000") & ".htm"
 

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