MS Excel do not copy the color theme automatically -
i using ms excel 2010 company uses set of standard color scheme / theme ms excel 2010 .i gave name (companycolor). have template contains color scheme , macro in perform tasks. when press macro button makes copy of activesheet,protect , email intended recipient.problem when macro makes copy of activesheet new workbook doesn't copy color scheme / theme template have, mean company color scheme (companycolor) due cells color, color of charts , shapes disturbed , changed according excel default color scheme seems odd. have way forward overcome issue or suggestion in regards
here link of snap shot!, understand problem better *>>here vba code makes copy of active worksheet active workbook new workbook, protect , email it.***
private sub commandbutton2_click() dim fileextstr string dim fileformatnum long dim sourcewb workbook dim destwb workbook dim tempfilepath string dim tempfilename string dim outapp object dim outmail object if (range("aq5") <> "") or (range("aq6") <> "") range("a5").select application .screenupdating = false .enableevents = false end set sourcewb = activeworkbook application.screenupdating = false activesheet.copy range("a14").clearcontents activesheet.protect password:="1234567890" set destwb = activeworkbook destwb if val(application.version) < 12 fileextstr = ".xls": fileformatnum = -4143 else if sourcewb.name = .name application .screenupdating = true .enableevents = true end msgbox "your answer no in security dialog" exit sub else select case sourcewb.fileformat case 51: fileextstr = ".xlsx": fileformatnum = 51 case 52: if .hasvbproject fileextstr = ".xlsm": fileformatnum = 52 else fileextstr = ".xlsx": fileformatnum = 51 end if case 56: fileextstr = ".xls": fileformatnum = 56 case else: fileextstr = ".xlsb": fileformatnum = 50 end select end if end if end tempfilepath = environ$("temp") & "\" tempfilename = "di status " & range("a17") & " dated " & format(now, "dd-mmm-yy h-mm-ss") set outapp = createobject("outlook.application") set outmail = outapp.createitem(0) destwb .saveas tempfilepath & tempfilename & fileextstr, fileformat:=fileformatnum on error resume next outmail .to = range("aq6").value .cc = range("aq7").value .bcc = "" .subject = range("aq8").value .body = range("aq9").value .attachments.add destwb.fullname .display application.wait (now + timevalue("0:00:00")) application.sendkeys "%s" end on error goto 0 .close savechanges:=false end kill tempfilepath & tempfilename & fileextstr set outmail = nothing set outapp = nothing application .screenupdating = true .enableevents = true end application.screenupdating = true set sourcewb = nothing set destwb = nothing set outapp = nothing set outmail = nothing msgbox ("project status has been sent") else msgbox "there must atleast 1 contact in to, or cc, field" end if end sub
below xml coding of color scheme microsoft excel save when create new color scheme / theme , save configuration file called xml file in default path c:\users\**username**\appdata\roaming\microsoft\templates\document themes\theme colors
so far have reached conclusion anyhow if able incorporate below xml code above vba code can desired result. dont know how.
<?xml version="1.0" encoding="utf-8" standalone="true"?> -<a:clrscheme name="mycompanytheme" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"> -<a:dk1> <a:sysclr lastclr="000000" val="windowtext"/> </a:dk1> -<a:lt1> <a:sysclr lastclr="ffffff" val="window"/> </a:lt1> -<a:dk2> <a:srgbclr val="1f497d"/> </a:dk2> -<a:lt2> <a:srgbclr val="eeece1"/> </a:lt2> -<a:accent1> <a:srgbclr val="d60037"/> </a:accent1> -<a:accent2> <a:srgbclr val="b21dac"/> </a:accent2> +<a:accent3> -<a:accent4><a:srgbclr val="ffce00"/> </a:accent4> -<a:accent5> <a:srgbclr val="009dd9"/> </a:accent5> -<a:accent6> <a:srgbclr val="af0637"/> </a:accent6> -<a:hlink><a:srgbclr val="80076b"/> </a:hlink> -<a:folhlink><a:srgbclr val="218535"/> </a:folhlink> </a:clrscheme>
finally found way worked!
describing solution others can this! here conclusion , worked! first of giving convenient path vba code,paste on file has specific color scheme theme.
activeworkbook.theme.themecolorscheme.save("c:\mythemecolorscheme.xml")
the above code generate xml file in specified path.
then, paste below line of code giving same path xml file resided, above "email sending" code.
activeworkbook.theme.themecolorscheme.load("c:\mythemecolorscheme.xml")
now copy theme in new workbook.
by default theme configuration reside on
"c:\users\username\appdata\roaming\microsoft\templates\document themes\theme colors\themefile.xml")
Comments
Post a Comment