Converting Excel to CSV format

me_gem69

New Member
Joined
May 23, 2011
Messages
9
I am trying to convert excel to csv format & am successful in this part.
I am facing a problem when i give the path of my server to save the file
but when i store it on my local machine it works fine.
Plz help me with this how can i pass the server location

Code:
--------------------------
Public Sub SaveWorksheetsAsCsv()
Dim WS As Excel.Worksheet
Dim SaveToDirectory As String

SaveToDirectory = "C:\"

For Each WS In ThisWorkbook.Worksheets
WS.SaveAs SaveToDirectory & WS.Name, xlCSV
Next

End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
You don't say what the server path is but you would specify it like this:-
Code:
ServerPath=[URL="file://\\servername\sharename\subfolder\"]\\servername\sharename\subfolder\[/URL]

Check this Wiki page: http://en.wikipedia.org/wiki/Path_(computing) (scroll down to Uniform Naming Convention).
 
Upvote 0
After giving the server path is giving an error
Run Time error '1004':
Method 'SaveAs' of object '_Worksheet' failed.

Code:
------------------------------------------------
Public Sub SaveWorksheetsAsCsv()
Dim WS As Excel.Worksheet
Set WS = ThisWorkbook.Sheets("All Parts")


WS.SaveAs Filename:="/opt/shared/apps/vistaarspares/3.7.5/vito/bin/Parts.csv", FileFormat:=xlCSV

End Sub
 
Last edited:
Upvote 0
Yes but you didn't format the UNC name like I showed you. (Sorry, I didn't notice that the forum software stripped away the quotes but I think realised that.)

It should look like this:-
Code:
Filename:="\\servername\sharename\subfolder\"

Is opt the name of your server?

Did you check that Wiki page?
 
Last edited:
Upvote 0
no opt is the name of the folder
its an Unix based server

/opt/shared/apps/vistaarspares/3.7.5/vito/bin/ ---is the folder location

Ya i checked the wiki page but didnt help
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

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