macros - checking if a file already exist using VBA powerpoint -


i want check if filename exist. wrote works when test in local desktop. filenames saved in sharepoint. when tested there, doesn't work! error message: bad file name or number. wrote:

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  'for debug (can remove later) 'msgbox ownpathname 'msgbox fullfilename    dim strfile             string  dim filefound           boolean   filefound = false  'look types of powerpoint files (filter powerpoint files save time)  strfile = dir(ownpathname & "\*pptm*")   while len(strfile) > 0  if instr(strfile, newfilename) > 0     filefound = true     exit end if strfile = dir loop  if filefound msgbox "modification done" else removetextboxes allblackanddate saveallpresentations (fullfilename) end if  end sub 

i don't understand why doesn't work! can me please solve problem? in advance!

i think may work, use time loop through directories on pc or network have access to.

f = dir(strfile, 7)  'sets f equal first file name while f <> ""        'loops until there no more files in directory   if instr(strfile, newfilename) > 0     filefound = true     exit  end if      f = dir            'set f equal next file name in directory  loop 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -