0

I have a EXCEL VBA 'export to PDF' app that uses DIR to verify the EXP_PDF.dll file exists. The function returns the file, but the file is actually located in a directory different than what (I think) the DIR path points to. I built the following simple sub to test:

Sub RetrieveFile()
Dim Shex As Object

Set Shex = CreateObject("Shell.Application")

file = Dir(Environ("commonprogramfiles") & "\Microsoft Shared\OFFICE" & Format(Val(Application.Version), "00") & "\EXp_PDF.DLL")

Path = Environ("commonprogramfiles") & "\Microsoft Shared\OFFICE" & Format(Val(Application.Version), "00")

targetFile = Path & "\EXp_PDF.DLL"

  If Len(file) > 0 Then

    MsgBox (targetFile & " Exists")
    Debug.Print targetFile

    FileCopy targetFile, "C:\Temp\exp_pdf.dll"


   tgtfile = targetFile
   Shex.Open (tgtfile)

  Else

    MsgBox ("File Doesn't Exist")

  End If

End Sub
  1. The DIR function returns the file name with length greater than 0
  2. msgbox displays a path. (but there are no files in the directory. Searching windows finds the file in a different directory.)
  3. the "file copy" code is copies the file to the temp directory
  4. The "file open" code launches but reports that the file cannot be found

Background: We have engineering logbook built in excel that uses a VBA app to export to pdf and email. It looks like the code originated on MSDN and was probably built for office 2007. Recently WIN 10 Office 16 computers did a windows update and the code now fails. I restored function by commenting out the search for the EXP_PDF.dll but I would like to know why the DIR function seems to be finding the dll in other location and yes hidden and windows files are set to shown. Thanks.

dlls4e
  • 1

1 Answers1

2

EXp_PDF.DLL is actually located in "C:\program files (x86)\Microsoft Office\root\vfs\ProgramFilesCommonX86\Microsoft Shared\OFFICE16". There are 95 files in this directory and 1 file in "C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE16".

It appears that the VBA is using a Virtual File System (note ..\vfs).

EXp_PDF.DLL Directory

Virtual File Systems allow applications to effective merge multiple directories.
In this way, when you refer to one directory you refer to all the directories in the merge. This makes it so the Application can run seamlessly no matter where it is installed.

I believe that this file system actually exists internally. Running the Msgbox below from an Office product returns 96 and VBScript returns 1.

MsgBox CreateObject("Scripting.FileSystemObject").GetFolder("C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE16").Files.Count

public static void main(String[] args) throws IOException {
    File folder = new File("C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\OFFICE16");

Java also list 1 file.

enter image description here

Getting the filenames of all files in a folder


File[] listOfFiles = folder.listFiles();

    for (int i = 0; i < listOfFiles.length; i++) {
      if (listOfFiles[i].isFile()) {
        System.out.println("File " + listOfFiles[i].getName());
      } else if (listOfFiles[i].isDirectory()) {
        System.out.println("Directory " + listOfFiles[i].getName());
      }
    }