Solved

Dot in Folder Name

Posted on 2013-11-25
8
448 Views
Last Modified: 2013-11-25
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
0
Comment
Question by:Rayne
8 Comments
 
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 40 total points
ID: 39673953
This does work.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 460 total points
ID: 39673958
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$()
    Loop
   
End Sub

Open in new window

0
 

Author Comment

by:Rayne
ID: 39673963
This is Awesome :)
Thank you  a million GrahamSkan

Respect
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 39673964
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
0
 

Author Comment

by:Rayne
ID: 39673966
Thank you Teylyn
0
 

Author Comment

by:Rayne
ID: 39674252
Hello All,

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

Thank you
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39674264
MkDir "C:\MyFolder\MySub.Folder"
0
 

Author Comment

by:Rayne
ID: 39675070
Awesome Graham :)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question