Solved

putting quotes around a string in VB Script  -  Windows 7

Posted on 2014-03-04
3
301 Views
Last Modified: 2014-03-04
Experts,

I have a string that has the address of a directory.  I just built this string and now I want to see if it exists.  How do I add quotation marks around the directory?

Currently string  myDir has the value below in it.



myDir= \\Main\FolderA\FolderB\FolderC\FolderD

I need  "\\Main\FolderA\FolderB\FolderC\FolderD"  to test the presence of the folder
0
Comment
Question by:morinia
3 Comments
 
LVL 8

Expert Comment

by:5teveo
ID: 39904467
Try

myDir= '"\\Main\FolderA\FolderB\FolderC\FolderD"' <--singles quotes on outside of string

myDir= ""\\Main\FolderA\FolderB\FolderC\FolderD"" <--2 double quotes on outside of string

myDir= """\\Main\FolderA\FolderB\FolderC\FolderD""" <--3 double quotes on outside of string
0
 
LVL 53

Accepted Solution

by:
Bill Prew earned 300 total points
ID: 39904530
I use a small function for this, as shown below:

myDir = Quote("\\Main\FolderA\FolderB\FolderC\FolderD")

' Small routine to add double quotes around a string
Function Quote(strText)
   Quote = Chr(34) & strText & Chr(34)
End Function

Open in new window

~bp
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39904563
You don't need quotation marks if myDir is a string variable, just pass myDir to your function that tests the path.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

773 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