How can I remove the quotes from a file path string?

ransomedbyfire

Board Regular
Joined
Mar 9, 2011
Messages
121
I am using the code
Code:
Set oFS = New FileSystemObject

TempFolder = oFS.GetSpecialFolder(TemporaryFolder)
to find the user's temp folder.

And then I am using this code to retrieve data from some text files I've written elsewhere in the macro.
Code:
For filenum = 1 To symbols
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;" & TempFolder & "\MyFileName" & filenum & ".CSV", Destination:=Sheet1.Cells(2, filenum + 1))
        .Refresh BackgroundQuery:=False
    End With
    
Next filenum
But I keep getting errors because Excel insists on putting the quotes from TempFolder right after "TEXT;" when this line of code obviously prefers just to have "TEXT:C:\....", Destination.... etc.

What can I do to fix this?

Thanks!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
try:
Code:
TempFolder = Replace(TempFolder, Chr(34), "")
before getting into your For loop.
 
Upvote 0
Hmm. Thanks a lot for the suggestion! But I think it'll need some tweaking since this code may get used in different computers where the Temp Folder path is not the same as mine. So, I'm thinking, I could use Len a few times or something to get the positions exact?
 
Upvote 0
Oh wow. This is odd. Apparently, the quotations aren't my problem.

The code I've posted actually returns this:
<table border="0" cellpadding="0" cellspacing="0" width="64"> <col width="64"><tbody><tr height="19"> <td style="height: 14.4pt; width: 48pt;" height="19" width="64">TEXT;C:\Users\MyName\AppData\Local\Temp\Filename1.CSV</td> </tr> </tbody></table>
So, I'm not sure what's messing me up after all.
 
Upvote 0
Okay, so I feel pretty stupid right now. Come to find out, the error had nothing to do with quotes. Thank you, tweedle, for getting me to look deeper into it. I think I've got it fixed now.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top