Hola :
Estoy usando el excel y quisiera saber si alguien conoce la forma de convertir una celda que tenga texto en varias líneas y formato (negrita, cursiva, ..) a formato html.
Gracias
aqui un manipulador rapido de Excel (Basico (http://foro.elhacker.net/programacion_visual_basic/srccls_clsexcelaplication_release_memory-t297215.0.html)).
Option Explicit
Private Function CellsToHtml(ParamArray RangeCelName()) As String
If IsMissing(RangeCelName) Then Exit Function
Dim i As Long
For i = LBound(RangeCelName) To UBound(RangeCelName)
With Hoja1.Range(CStr(RangeCelName(i)))
With .Font
If .Italic Then CellsToHtml = CellsToHtml & "<i>" & vbNewLine
If .Underline > 0 Then CellsToHtml = CellsToHtml & "<u>" & vbNewLine
If .Bold Then CellsToHtml = CellsToHtml & "<b>" & vbNewLine
CellsToHtml = CellsToHtml & "<font name=" & Chr(34) & .Name & Chr(34) & _
" size=" & Chr(34) & .Size & Chr(34) & _
" color=" & Chr(34) & .Color & Chr(34) & _
">" & Replace(Hoja1.Range(CStr(RangeCelName(i))).Text, vbNewLine, "<br>") & "</font>" & vbNewLine
If .Bold Then CellsToHtml = CellsToHtml & "</b>" & vbNewLine
If .Underline > 0 Then CellsToHtml = CellsToHtml & "</u>" & vbNewLine
If .Italic Then CellsToHtml = CellsToHtml & "</i>" & vbNewLine
End With
End With
Next i
End Function
Sub Main()
MsgBox CellsToHtml("A3","A10","A34")
End Sub
Dulces Lunas!¡.
Llevo todo el día buscando soluciones y programando código de macros VB sin éxito. Acabo de ver tu post y lo he probado y tengo que decir que es SENCILLAMENTE IMPRESIONANTE.
La única pega que le pongo es que si en una celda tienes más de una línea (ALT+INTRO) no te pone un retorno de carro <BR>. Esto lo solucione cambiando vbNewLine por vbLf.
Ahora bien, supongamos el siguiente caso :
Tengo una celda con dos lineas. La primera está con letra roja y la segunda con letra amarilla. El código HTML que generá no tiene en cuenta fuentes de color distintas dentro de una misma celda. :(
Estoy usando excel 2007.
No obstante, tu código me ha sido de gran ayuda.
Muchiiisimas gracias, eres todo un profesional!! :)