Option Explicit Declare Function ShellExecute Lib "Shell32.dll" _ Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal _ lpOperation As String, ByVal lpFile As _ String, ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal _ nShowCmd As Long) As Long Declare Function GetForegroundWindow Lib "user32" () As Long Public filename As String 'Omitted here because it is also in McRitchie_BuildTOC ' Sub DelHyperLinks() ' 'David McRitchie ' Selection.Hyperlinks.Delete ' End Sub Sub spintest201() Dim Cell As Range 'just testing For Each Cell In Selection Cell.Value = Cell.MergeArea.Cells(1).Address _ & " " & Cell.MergeArea.Columns.Count _ & " " & Cell.MergeArea.Rows.Count Next Cell End Sub Sub spintest202() Dim c As Long, r As Long For r = 1 To Selection.Rows.Count For c = 1 To Selection.Columns.Count If Selection.Cells(r, c).Address = Selection.Cells(r, c).MergeArea.Cells(1).Address Then Selection.Cells(r, c).Value = Selection.Cells(r, c).MergeArea.Cells(1).Address _ & " -- " & Selection.Cells(r, c).MergeArea.Columns.Count _ & " " & Selection.Cells(r, c).MergeArea.Rows.Count _ & " " & Selection.Cells(r, c).HorizontalAlignment End If Next c Next r End Sub 'DelHyperLinks, delete hyperlinks for selection ' suggested use on email addresses, if converting to HTML 'XL2HTML, Convert selection to HTML 'XL2HTMLx, Convert selection to HTML with row/column headers ' does not yet include color changes, etc. Sub XL2HTMLx() Call [personal.xls].XL2HTML_Main(1, "OC") 'column and row headings with shading MsgBox "Xl2HTMLx ended" End Sub Sub XL2HTML() Call XL2HTML_Main(0, "OC") 'default no column nor row headings End Sub Sub XL2HTMLa() 'David McRitchie 2003-02-09 Separate Areas based on marksepareas Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Dim I As Long, optFile As String Dim mareas As Range Set mareas = Selection MsgBox mareas.Address(0, 0) For I = 1 To mareas.Areas.Count mareas.Areas(I).Select optFile = "" If I = 1 Then optFile = "O" 'letter o If I = mareas.Areas.Count Then optFile = optFile & "C" Call XL2HTML_Main(1, optFile) '0 no shading /1 shaded headers Next I mareas.Select Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub Sub XL2HTMLs() 'Example: output multiple selected sheets... Dim optFile As String Dim shtCnt As Long Dim mshtCnt As Long Dim sht As Variant shtCnt = 0 mshtCnt = Application.ActiveWorkbook.Windows(1).SelectedSheets.Count For Each sht In Application.ActiveWorkbook.Windows(1).SelectedSheets Sheets(sht.Name).Select shtCnt = shtCnt + 1 optFile = "" If shtCnt = 1 Then optFile = "O" 'letter o If shtCnt = mshtCnt Then optFile = optFile & "C" Cells.Select Call XL2HTML_Main(0, optFile) Next sht End Sub Sub XL2HTML_Main(Optional shading As Long, _ Optional opt2 As String, _ Optional optOutputFile As String) 'O=open,C=Close,""=default, 1=special, T=Time 'Original coding and concept is based on 'http://www.herber.de/mailing/020598v.txt ' Hans W. Herber * Microsoft Excel MVP 'Major changes D.McRitchie, 1998-08- msgbox, close, ' http://www.mvps.org/dmcritchie/excel/xl2htmlx.txt ' Shading option, Column & ROW headings and will use center justification ' when specifically formatted into Excel. 'Additional help Invoking IExplorer from VBA - ' From: "Chris Rae" posted Excel.programming 9Jun1999 'rev. 2000-06-25, hyperlinks for http:// (not email) ' Include Bold, Italic, Color (black for email) 'rev. 2000-07-01, handle merged cells (Rob Bruce), ' additional changes: center justification, ' multiple cells with TR "line", if fits in 80 bytes, ' XL2HTML_Main will be used by both XL2HTML and XL2HTMLx, ' center justification. Rev. 2000-07-02 added
for Chr(10) 'rev. 2000-07-03 for Center Across Selection (cell format) 'rev. 2001-08-11 multiple sheets, entire used content from each 'rev. 2001-08-11 for optional output dataset name in parameters 'rev. 2002-07-25 to right align numbers by default 'rev. 2002-08-24 to not right align empty cells 'Planning -- revision possibilities: ' Plan. Multiple Areas from within the main subroutine, ' Plan. -- might be useful for saving paper (snake columns) ' Plan. ** might interfere with multiple sheets that is ' Plan. setup to only process entire used ranges. ' Plan. see coding in excel/join.htm#marksepareas or merge.htm Dim r%, c% Dim nr As Long, nC As Long Dim lastcell As Range 'Dim xtra As Long 'Dim filename As Variant 'Dim shadehd As Variant Dim retval As Variant Dim x As String Dim shadehd As String: shadehd = " bgcolor=""#d8d8d8""" Dim I As Long, iPos As Long Dim newx As String 'Worksheets(1).Select nr = Selection.Rows.Count nC = Selection.Columns.Count Set lastcell = Cells.SpecialCells(xlLastCell) If nr > lastcell.Row Then nr = lastcell.Row If nC > lastcell.Column Then nC = lastcell.Column 'iRows = Selection.Rows.Count 'iColumns = Selection.Columns.Count 'To Be Added: radio buttons, Row hdr, Col hdr, Shade hdr ' include suggested filename of c:\temp\XL2test.htm '(I include that file in my browsers bookmarks/favorites) filename = "c:\temp\XL2test.htm" If optOutputFile <> "" Then filename = optOutputFile If InStr(opt2, "O") Then filename = InputBox("Supply filename for HTML generated from " _ & "selected range", "Filename for XL2HTML", filename) End If If InStr(opt2, "O") Or InStr(opt2, "1") Then Close #1 Open filename For Output As 1 End If If InStr(opt2, "O") Then Print #1, "" Print #1, "