Results 1 to 4 of 4
  1. #1
    gar is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Nov 2011
    Posts
    42

    To quote or not to quote...

    In a VBA procedure I found that FileExists("<pathname>") returned False while: FileExists(<pathname>) returned True. Is this what is to be expected? If the pathname is obtained by cutting and pasting from File Explorer, it comes with the quotation marks; is there a means, other than manual editing, by which they can be removed?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Possibly use Replace() function to remove quote marks.

    Whether or not quotes are included depends on method of copy.

    Post your code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    gar is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Nov 2011
    Posts
    42
    Quote Originally Posted by June7 View Post
    Possibly use Replace() function to remove quote marks.

    Whether or not quotes are included depends on method of copy.

    Post your code.
    Thanks for your message.

    Public Sub quotest()

    Dim fs As FileSystemObject
    Dim filename As String

    filename = InputBox("Filename?", , 0)
    Set fs = New Scripting.FileSystemObject
    Debug.Print fs.FileExists(filename)

    End Sub

    If "filename" is enclosed in double quotation marks, this returns "False", without quotation marks it returns "True". Confusingly, if I enter:

    Set fs = New Scripting.FileSystemObjectebug.Print fs.FileExists(<filename>)

    in the Immediate Widow, the opposite is the case, i.e. <filename> with quotations marks yields True otherwise, False.


  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Your code doesn't work for me, just get compile errors.

    This does work for me:
    Code:
    Public Sub quotest()
    Dim fs As Object
    Dim filename As String
    filename = InputBox("Filename?", , 0)
    Set fs = CreateObject("scripting.filesystemobject")
    Debug.Print fs.FileExists(filename)
    End Sub
    
    Putting a full file path of existing file into InputBox returns True. Test with <> characters errors.


    Is this your actual code or just something for testing? I would not use InputBox for user input of file path/name.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. best way to include quote in field
    By mdavid in forum Access
    Replies: 14
    Last Post: 10-17-2017, 04:45 AM
  2. Quote to Job
    By dinsey90 in forum Access
    Replies: 13
    Last Post: 09-26-2017, 02:02 AM
  3. Single Quote in Cascading Combo Box
    By crockee in forum Programming
    Replies: 3
    Last Post: 05-28-2016, 07:23 AM
  4. Quote Database
    By jimbob in forum Database Design
    Replies: 1
    Last Post: 03-17-2014, 05:14 PM
  5. Replies: 0
    Last Post: 08-06-2010, 06:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums