Solved

Dot in Folder Name

Posted on 2013-11-25
8
457 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
Independent Software Vendors: 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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
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.

749 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