Sending Refreshed Excel Sheet Every Workday using VBA Excel/Outlook -
every day @ 3pm have send out excel workbook colleague. macro in workbook copies cells in 1 sheet , paste special sheet , saves workbook. have written macro , send email address, struggle have sent automatically. have instructed scheduling tasks already, don't know how make link between opening excel, performing marco, saving workbook , sending specified person. code below - help.
sub fixing() sheets("sheet2").select activewindow.smallscroll down:=-9 cells.select selection.copy sheets("sheet1").select range("a1").select selection.pastespecial paste:=xlpastevaluesandnumberformats, operation:= _ xlnone, skipblanks:=false, transpose:=false range("i7").select application.cutcopymode = false activeworkbook.save dim outapp object dim outmail object set outapp = createobject("outlook.application") set outmail = outapp.createitem(0) on error resume next outmail .to = "" .cc = "" .bcc = "my email address" .subject = "daily email" .body = "" .attachments.add ("f:\excel models\daily email.xlsm") .send end on error goto 0 set outmail = nothing set outapp = nothing end sub
create vbscript file
e.g. start excel action.vbs
following code inside:
dim exl set exl = createobject("excel.application") 'not required exl.visible = true 'your file , macro exl.workbooks.open "full path excel file including extension here" exl.run "fixing" 'close exl.quit set exl = nothing
save file , set windows task scheduler
to run vbs
file @ 3 pm.
Comments
Post a Comment