vba - Code for checking to see if a new message with a specific subject line has been already created Lotus -
i'm not programmer apologize in advance.
i have 3 different worksheets in workbook. each sheet has specific macro after numbers entered, shift supervisors can press button assigned macro , metrics sheet copied , pasted different worksheet in format filter-able/pivot-able columns. saves , closes data, goes shift report worksheet, copies pertinent cells, opens lotus , formats new message subject line stating correct shift number , date , pastes shift report data body of e-mail.
since there different button press on 3 worksheets, , can't count on supervisors enter numbers in specific order, need able tell if lotus has opened , created e-mail specific subject line see if needs created or if exists information in body. know if possible?
dim nsession object dim ndatabase object dim nuiworkspace object dim ndoc object dim nuidoc object dim wordapp object dim worddoc object dim msg string msg = "leads report " & now() & vbnewline & vbnewline & _ "finishing:" & vbnewline & _ "**paste leadsheet cells here**" & vbnewline & vbnewline sheets("leadsheet").select set newrange = range("e4") mystring = rangetostring(newrange) set nsession = createobject("notes.notessession") set nuiworkspace = createobject("notes.notesuiworkspace") set ndatabase = nsession.getdatabase("", "") if not ndatabase.isopen ndatabase.openmail end if 'create new document '******************************(if statement see 'if document specific subject line has been 'created....'subject = doc.getitemvalue("subject")(0)??????? '**************************************** set ndoc = ndatabase.createdocument ndoc .sendto = "email@email.com" 'change .copyto = "" .subject = format(date, "mm-dd-yyyy") & " lead report shift " & mystring 'email body text, including marker text replaced excel cells .body = msg .save true, false end 'edit just-created document copy , paste excel cells set nuidoc = nuiworkspace.editdocument(true, ndoc) 'find marker text in body item 'replace excel cell nuidoc 'leadsheet workbooks("master shift report sheet.xlsm").activate sheets("leadsheet").select range("b2:o62").select activewindow.zoom = 86 selection.copy set wordapp = createobject("word.application") set worddoc = wordapp.documents.add wordapp.selection .pastespecial datatype:=4 & vbnewline .wholestory .copy end .gotofield ("body") .findstring "**paste leadsheet cells here**" .paste 'application.cutcopymode = false '.send '.close end set nsession = nothing
anything else looks wonky don't hesitate point out! i'm learning.
wiki
Comments
Post a Comment