Quote marks around file names

B

Bear

When I use Dialogs(wdDialogFileOpen).Name, a name with space characters in it
is returned in quotes. A single-string name is returned without quotes.

Does anyone have any optimized code they'd like to share to handle this
situation? All I can think of is to test the first character and od
Mid(.Name, 2, Len(.Name) - 2).

Is that about as good a way as any?

Bear
 
K

Karl E. Peterson

Bear said:
When I use Dialogs(wdDialogFileOpen).Name, a name with space characters in it
is returned in quotes. A single-string name is returned without quotes.

Does anyone have any optimized code they'd like to share to handle this
situation? All I can think of is to test the first character and od
Mid(.Name, 2, Len(.Name) - 2).

Is that about as good a way as any?

Hmmmm, not sure what you're trying to accomplish? My best guess is that you want to
remove all quote characters? If so,

TheFileName = Replace(.Name, """", "")

oughta do.
 
B

Bear

Karl:

That's exactly what I'm trying to do, and you've suggested a neat way to do
it.
Thanks.

Bear
 
J

Jay Freedman

Bear said:
When I use Dialogs(wdDialogFileOpen).Name, a name with space
characters in it is returned in quotes. A single-string name is
returned without quotes.

Does anyone have any optimized code they'd like to share to handle
this situation? All I can think of is to test the first character and
od Mid(.Name, 2, Len(.Name) - 2).

Is that about as good a way as any?

Bear

The statement

strFN = Replace(strFN, """", "")

will return the result without quotes regardless of whether it had them.

The only caveat is that the Replace function didn't exist in Word 97 VBA. If
that's a problem, there are substitutes available on the Web, such as
http://www.vbforums.com/archive/index.php/t-243433.html.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
B

Bear

Jay:

Thanks! For my purposes Word 2000 is the earliest I have to worry about, so
this is a dandy solution.

Bear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top