vba - Actualize a document with weekly Excel received through outlook -
i trying update information in dashboard information received 2 excel sheet received weekly in 2 documents (infoprivate, infopublic).
my dashboard contains (basically) 2 sheets (infoprivate, infopublic), , others make local calculus.
how can update info ny looking mos recent email , change each of 2 sheets data recent version?
my actual code follow:
public sub saveolattachmentspu() dim isattachment boolean dim olfolder outlook.mapifolder dim msg outlook.mailitem dim att outlook.attachment dim sht worksheet, wb1, wb2 workbooks on error goto crash isattachment = false set olfolder = outlook.getnamespace("mapi").folders(1) set olfolder = olfolder.folders("inbox") if olfolder nothing exit sub each msg in olfolder.items if ucase(msg.subject) = "pac paho sales current year" while msg.attachments.count > 0 set wb1 = msg.attachements.open wb1.sheets("pac paho sales current year").copy 'on copie la feuille de la piece jointe set sht = activesheet 'on récupère la copie dans un objet sht.copy activeworkbook.sheets("paho").paste wb1.close activeworkbook.saveas filename:=myfilename, fileformat:=xlsm set sht = nothing: set wb1 = nothing: set wb2 = nothing: isattachment = true wend msg.delete end if next exit sub crash: msgbox ("booom") end sub
it doesn´t work !!! , don t have clue why...
thanks lot whoever can me! dav
you need
- some way auto save last received e-mail predefined location (google give ton of results)
- assuming use excel dashboard, rebuild , use power query import data files in predefined location
- power query reread source excel sheets , update dashboard
Comments
Post a Comment