AronGahagan / cpt-dev

Code repository for the ClearPlan Toolbar
https://www.ClearPlanConsulting.com
3 stars 1 forks source link

cptResourceDemand - work with URL in filename #347

Closed AronGahagan closed 11 months ago

AronGahagan commented 11 months ago

Problem:

If ActiveProject.Name returns a url, the path builder fails.

  strFile = oShell.SpecialFolders("Desktop") & "\" 
  strFile = strFile & Replace(Replace(ActiveProject.Name, ".mpp", ""), " ", "_") 
  strFile = strFile & "_ResourceDemand" & Format(Now(), "yyyy-mm-dd-hh-nn-ss") & ".csv"

Solution:

Use Regex:

  strFile = cptRegEx(ActiveProject.Name, "[^\\/]{1,}$") 'works with local, server, and sharepoint
  strFile = Replace(strFile, ".mpp", "") 'remove .mpp if local
  strFile = Replace(strFile, " ", "_") 'replace spaces with
  strFile = oShell.SpecialFolders("Desktop") & "\" & strFile
  strFile = strFile & "_ResourceDemand" & Format(Now(), "yyyy-mm-dd-hh-nn-ss") & ".csv"

The above should work for local files, projects on server, as well as files on a URL.

Todo:

AronGahagan commented 11 months ago

waiting on feedback from L