macros - VBA PowerPoint to check if a FileNma already exist -


what want check if file name exist , make my modification. tried several methode no 1 work!! can me please finding solution?

this wrote 3 different methods:

private sub commandbutton21_click() dim lretval long dim objfso object dim checkexists boolean  todate = datevalue(now) oldweekday = weekday(todate) select case oldweekday  case 1 newfilename = "pt pm weekly " & format(date + 4, "yyyymmdd") case 2 newfilename = "pt pm weekly " & format(date + 3, "yyyymmdd") case 3 newfilename = "pt pm weekly " & format(date + 2, "yyyymmdd") case 4 newfilename = "pt pm weekly " & format(date + 1, "yyyymmdd") case 5 newfilename = "pt pm weekly " & format(date, "yyyymmdd") case 6 newfilename = "pt pm weekly " & format(date + 6, "yyyymmdd") case 7 newfilename = "pt pm weekly " & format(date + 5, "yyyymmdd")  end select ownpathname = application.activepresentation.path fullfilename = ownpathname & "\" & newfilename msgbox ownpathname msgbox fullfilename '------------------------------------------------------------------- 'lretval = application.presentations.open(fullfilename) 'if lretval <> hfile_error '  msgbox "modification done" '------------------------------------------------------------------    'if dir(fullfilename) <> ""    'msgbox "modification done"  '-------------------------------------------------------------------         'set objfso = createobject("powerpoint.application")         'checkexists = objfso.fileexists(fullfilename)         'if checkexists = true         'msgbox "modification done" else deletetextbox allblackanddate lastmodifieddate saveallpresentations (fullfilename) end if end sub 

thank help!

try code below, check if newfilename of powerpoint presentation exists in same folder, , if bring-up msgbox wanted.

private sub commandbutton21_click()  dim newfilename             string dim ownpathname             string  oldweekday = weekday(now)  select case oldweekday      case 1         newfilename = "pt pm weekly " & format(date + 4, "yyyymmdd")     case 2         newfilename = "pt pm weekly " & format(date + 3, "yyyymmdd")     case 3         newfilename = "pt pm weekly " & format(date + 2, "yyyymmdd")     case 4         newfilename = "pt pm weekly " & format(date + 1, "yyyymmdd")     case 5         newfilename = "pt pm weekly " & format(date, "yyyymmdd")     case 6         newfilename = "pt pm weekly " & format(date + 6, "yyyymmdd")     case 7         newfilename = "pt pm weekly " & format(date + 5, "yyyymmdd")  end select  ownpathname = activepresentation.path fullfilename = ownpathname & "\" & newfilename  ' debug (can remove later) msgbox ownpathname msgbox fullfilename   dim strfile             string dim filefound           boolean  filefound = false ' types of powerpoint files (filter powerpoint files save time) strfile = dir(ownpathname & "\*ppt*")  while len(strfile) > 0     if instr(strfile, newfilename) > 0         filefound = true         exit     end if     strfile = dir loop  if filefound     msgbox "modification done" else     ' .... logics  end if  end sub 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -