Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FP VBA - Removing all attributes from TABLE element

Status
Not open for further replies.

itlee

Programmer
Feb 14, 2001
34
CH
I am trying to write some VBA code to remove all the attributes from the TABLE element, so far I have got:

Code:
Function RemoveFormattingFromTable()
    Dim fpPage As FPHTMLDocument
    Dim fpTable As FPHTMLTable
    Dim i As Integer
    Dim booResult As Boolean
        
    Set fpPage = ActiveDocument
    
    For i = 0 To fpPage.all.tags("table").Length - 1
        Set fpTable = fpPage.all.tags("table")(i)
        booResult = fpTable.removeAttribute("ACCESSKEY")
        booResult = fpTable.removeAttribute("ALIGN")
        booResult = fpTable.removeAttribute("BACKGROUND")
        booResult = fpTable.removeAttribute("BGCOLOR")
        booResult = fpTable.removeAttribute("BORDER")
        booResult = fpTable.removeAttribute("BORDERCOLOR")
        booResult = fpTable.removeAttribute("CELLPADDING")
        booResult = fpTable.removeAttribute("CELLSPACING")
        booResult = fpTable.removeAttribute("CLASS")
        booResult = fpTable.removeAttribute("COLS")
        booResult = fpTable.removeAttribute("DATAPAGESIZE")
        booResult = fpTable.removeAttribute("DATASRC")
        booResult = fpTable.removeAttribute("DIR")
        booResult = fpTable.removeAttribute("FRAME")
        booResult = fpTable.removeAttribute("HEIGHT")
        booResult = fpTable.removeAttribute("ID")
        booResult = fpTable.removeAttribute("LANG")
        booResult = fpTable.removeAttribute("LANGUAGE")
        booResult = fpTable.removeAttribute("RULES")
        booResult = fpTable.removeAttribute("STYLE")
        booResult = fpTable.removeAttribute("TABINDEX")
        booResult = fpTable.removeAttribute("TITLE")
        booResult = fpTable.removeAttribute("WIDTH")
    Next i

    Set fpTable = Nothing
    Set fpPage = Nothing
End Function

this will run ok, i.e. no syntax errors, etc. But, the booResult is always False and the attribute is still there!

I did write this once a few weeks ago, but someone deleted it and I now trying to remember how I did it.

Anyone got any other ideas? Please no java script.

ITLee. MCP\Dev\Prog\DBA\ITIL
 
Ah-Ha, I have found my mistake. I have missed off the last argument of the removeAttribute method which defines the case of the attribute.

So it should be

Code:
booResult = fpTable.removeAttribute("ACCESSKEY", 0)

which will remove for either ACCESSKEY or accesskey. If the last argument was defined as 1, it would only remove ACCESSKEY.

ITLee. MCP\Dev\Prog\DBA\ITIL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top