• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 591
  • Last Modified:

Dot in Folder Name

Hello All,

I want to know if this is possible - if a folder has dot (.) in its name - it is possible to be referenced  all right in a VBA code for copying file to that folder?

since there is always a problem as the code might think that the (.) means its a extension type and not a part of the folder name...like

folder name  - C:\DR\RRTTYU 2013.09.09

thank you

2 Solutions
Saqib Husain, SyedEngineerCommented:
This does work.
It depends on the code, but normally, yes:
Sub ListFiles()
    Dim strFileName As String
    Dim strFolder As String
    strFolder = "C:\DR\RRTTYU 2013.09.09"

    strFileName = Dir$(strFolder & "\*.*")
    Do Until strFileName = ""
        Debug.Print strFileName
        strFileName = Dir$()
End Sub

Open in new window

RayneAuthor Commented:
This is Awesome :)
Thank you  a million GrahamSkan

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:

the code does not "think" about characters in the folder name at all. If the operating system accepts dots in folder names, so will VBA. You can easily declare string variables, assign value to these variables and then use the in operations with files. For example:

Dim folder As String
Dim fileName As String

folder = "C:\testing\a folder with.a dot"
fileName = "MyWorkbook.xlsx"

    Workbooks.Open fileName:=folder & "\" & fileName

Open in new window

You don't have to use variables. You can use the folder name as  direct reference if you prefer.

    Workbooks.Open fileName:="C:\testing\a folder with.a dot\MyWorkbook.xlsx"

Open in new window

cheers, teylyn
RayneAuthor Commented:
Thank you Teylyn
RayneAuthor Commented:
Hello All,

My next question is  - is it possible to create a folder in VBA with (.) in the name?

Thank you
MkDir "C:\MyFolder\MySub.Folder"
RayneAuthor Commented:
Awesome Graham :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now