Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Mar 2007
    Wikltshire UK
    Thanked 0 Times in 0 Posts

    Save HTML as Text in VBA (VBA/Access 2007)

    Hi trying to get an Access Module with the "HTML Object Library 12 as a reference" to save an html File as text (IE the content not the HTML tags). I think this is probably something to do with .innnertext. The line below with ** is the one I think I need to change, but i need confirmation that the Set ieapp file type is correct also.

    Any help you can give we would be great. TX.

    Dim ieapp As Object
    Set ieapp = CreateObject("Microsoft.XMLHTTP")
    Filen = File.Name
    myUrl = "CocProcessingDocFiles" & Filen
    Filen = Left(Filen, Len(Filen) - 4)
    ieapp.Navigate myUrl
    ieapp.Visible = True
    Do: Loop Until ieapp.Busy = False
    ** ieapp.SaveAs FileName:="CocProcessingTXTFiles" & Filen & ".txt", FileFormat:=xlTextMSDOS
    ieapp.Visible = False

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Save HTML as Text in VBA (VBA/Access 2007)

    Why don't you use Word to open the HTML file and save it as text?

    Dim wrdApp As Object
    Dim wrdDoc As Object
    Dim blnConfirm As Boolean
    Set wrdApp = CreateObject("Word.Application")
    blnConfirm = wrdApp.Options.ConfirmConversions
    Set wrdDoc = wrdApp.Documents.Open(Filename:="H:WordTest.htm", ConfirmConversions:=False)
    wrdDoc.SaveAs Filename:="H:WordTest.txt", FileFormat:=2 ' wdFormatText
    wrdApp.Options.ConfirmConversions = blnConfirm
    wrdApp.Quit SaveChanges:=False
    Set wrdDoc = Nothing
    Set wrdApp = Nothing

    Change the paths and filenames as needed.

Posting Permissions

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