Solved

Dot in Folder Name

Posted on 2013-11-25
8
475 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 50
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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
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 how to use a scrolling table in Microsoft Excel using the INDEX function.

688 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