Solved

Dot in Folder Name

Posted on 2013-11-25
8
433 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
 
LVL 50

Expert Comment

by:teylyn
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now