Groups | Search | Server Info | Login | Register


Groups > comp.apps.spreadsheets > #45

File reference syntax

From JHB <bakerjohnh@gmail.com>
Newsgroups comp.apps.spreadsheets
Subject File reference syntax
Date 2012-07-11 09:59 -0700
Organization http://groups.google.com
Message-ID <3c48ead7-7bdd-479a-a0e7-1d4ac799d741@m10g2000vbn.googlegroups.com> (permalink)

Show all headers | View raw


Hi:

I am attmpting to find out if a file exists using a routine copied
from someone else in the form of a visual baseic module. I am using a
puublic funcytion hat says the following:


Public Function FileFolderExists(strFullPath As String) As Boolean
'Author       : Ken Puls (www.excelguru.ca)
'Macro Purpose: Check if a file or folder exists
    On Error GoTo EarlyExit
    If Not Dir(strFullPath, vbDirectory) = vbNullString Then
FileFolderExists = True

EarlyExit:
    On Error GoTo 0
End Function

To call it, I am using a tailored function as follows:

Public Sub SchedImportTHERE()
'Author       : Ken Puls (www.excelguru.ca)
'Macro Purpose: Test if directory exists
    Sheets("FILELIST").Select

    Range("D2").Select
    Filename = ActiveCell()

    If FileFolderExists(Filename) Then
        MsgBox "File exists!"
    Else
        MsgBox "File does not exist!"
    End If
End Sub

The Contents of cell D2 is a constructed file reference based on
history. My problem is that while the actual value in D2 is 100%
correct, the way that I have set up the actual call to the
FileFolderExists function is wrong!

I know that it is in the way I have constructed the call and that
(Filename) is wrong. I just do not know how to fix it! If I substitute
the actual file address into Filename, ("C:/download/names.xls") it
works fine.

Help please

John baker

Back to comp.apps.spreadsheets | Previous | Next | Find similar


Thread

File reference syntax JHB <bakerjohnh@gmail.com> - 2012-07-11 09:59 -0700

csiph-web