add gridlines automatically to an openend xxx.html

  • Thread starter Thread starter claude allard
  • Start date Start date
C

claude allard

Greetings,
I have an html file that displays data in a table format. I can open
this file with Excel and it will display all the data in the proper
format. I would like to automatically apply grid lines to this data as
I open the file. The html file name will vary (generated by Webview
table generating tool). Is it possible to do this? I have a macro that
will apply the grid lines to the spread sheet but I have to go to
tools/macro/VBE and then add the code and run it. I have general users
opening these html files with Excel and they just want to see the data
with grid lines around it.

Any help would be greatly appreciated. TIA.

Claude Allard
 
Hi Claude,
I never use the builtin HTML but did you try using borders
instead of gridlines.
Select cells (Ctrl+A), Format, cells, border, ...
or use the toolbar icon for the formatting of selected cells.
 
David,
Thanks for the suggestion. The main problem with that method is that
the user has to do this. I'm looking for a way for Excel (or some other
process) to automatically do it for the user.
 
Hi Claude,
What kind of an answer are you looking for ?

You can have a macro with the Excel file.
If the Excel file is created with a template, you can change
the template to use borders.
If you have control of the Excel, then you wouldn't have a
problem so that's probably not the case.
Are there many different Excel files.

Who has control of the Excel file as it goes to Webview (guess
it's not Excel's conversion to HTML),

A macro to generate the borders is a bit complicated, so here
is what is generated from recording a macro with a slight change
of "selection." to "cells." . As you can see you have to set
each type of border Top, right, bottom, left, inside, and diagonals.

Sub Macro1()
Cells.Borders(xlDiagonalDown).LineStyle = xlNone
Cells.Borders(xlDiagonalUp).LineStyle = xlNone
With Cells.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Cells.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Cells.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Cells.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Cells.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Cells.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub
 
Hi David,
I looking for a way to open an arbirary .html file (which will have
table formated data in it) using Excel and in the process of opening it
a macro (or some other process) will add grid lines to the spread sheet.
The .html file would not previously contain the macro so I would want
Excel to either know based on the file type to apply the grid making
logic or for the user to be able to hit a control key to launch a macro
that Excel already knows about. This macro would have to be known by
Excel in advance because it would not be in the .html file being opened.
My question is 'can this be done?'.

Thanks for your thoughts.

Claude
 
Back
Top