Link to home
Start Free TrialLog in
Avatar of Rayne
RayneFlag for United States of America

asked on

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

Respect,
Rayne
SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rayne

ASKER

This is Awesome :)
Thank you  a million GrahamSkan

Respect
Hello,

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
Avatar of Rayne

ASKER

Thank you Teylyn
Avatar of Rayne

ASKER

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"
Avatar of Rayne

ASKER

Awesome Graham :)