excel - Export specific range into an HTML -
i trying export range ("a1:c10") sheet sheet1
html , save in same directory current workbook. want keep source formatting.
i using following code, errors , cannot define destination folder same folder current workbook resides.
sub export() dim rng range set rng = sheets("sheet1").range("a1:c10") activeworkbook.publishobjects.add( _ sourcetype:=xlsourcerange, _ filename:=file1, _ sheet:="sheet1", _ source:=rng, _ htmltype:=xlhtmlstatic).publish end sub
i tried this:
sub export() dim rng range set rng = sheets("sheet1").range("a1:c10") activeworkbook.publishobjects.add( _ sourcetype:=xlsourcerange, _ filename:="c:\exported.xlsx", _ sheet:="sheet1", _ source:=rng, _ htmltype:=xlhtmlstatic).publish end sub
source:=
expects string value address of range, not range
object.
the path of workbook contains macro can gotten thisworkbook.path
.
sub export() dim rng range file1 = thisworkbook.path & "\" & "test.html" set rng = sheets("tabelle1").range("a1:c10") activeworkbook.publishobjects.add( _ sourcetype:=xlsourcerange, _ filename:=file1, _ sheet:=rng.worksheet.name, _ source:=rng.address, _ htmltype:=xlhtmlstatic).publish end sub
Comments
Post a Comment