I need code to save a file with the following attributes. This path is on a network.
Name file string found in cell F1
Save file as .csv file
Save file to this path: H:\Private\Distribution\Small Package List\CSV
This file originates as an xlsm.
I need code to save a file with the following attributes. This path is on a network.
Name file string found in cell F1
Save file as .csv file
Save file to this path: H:\Private\Distribution\Small Package List\CSV
This file originates as an xlsm.
Last edited by Michael 1962; 03-08-2012 at 11:19 AM.
Maybe:
[vba]
ChDir "H:\Private\Distribution\Small Package List\CSV"
ActiveWorkbook.SaveAs _
Filename:= "H:\Private\Distribution\Small Package List\CSV\Sample Test.csv", _
FileFormat:=xlCSV, _
CreateBackup:=False
[/vba]
Regards, TMS
[vba]
Sub file_SaveAs()
Dim wb As Workbook, ws As Worksheet
Dim fPath As String, fName As String
Set wb = ThisWorkbook 'refers to workbook that contains this macro
'or
'Set wb = ActiveWorkbook 'refers to workbook which is currently active
'or
'Set wb = Workbooks("MyBook.xlsm")
Set ws = wb.Worksheets("Sheet1") 'change to suit
'or
'Set ws = wb.ActiveSheet
fPath = "H:\Private\Distribution\Small Package List\CSV"
If Right(fPath, 1) <> "\" Then fPath = fPath & "\"
fName = ws.Range("F1").Value
wb.SaveAs Filename:=fPath & fName, FileFormat:=xlCSV
End Sub
[/vba]
PLS DO NOT PM; OPEN A THREAD INSTEAD!!!
1) Posting Code
[CODE]PasteYourCodeHere[/CODE]
(or paste your code, select it, click # button)
2) Uploading File(s)
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.
3) Testing the Codes
always back up your files before testing the codes.
4) Marking the Thread as Solved
from Thread Tools (on the top right corner, above the first message)