72gsdroptop
New Member
- Joined
- Aug 25, 2005
- Messages
- 10
Hello!
I have searched for this but cannot find a suitable answer. I have been tasked with modifying a coworkers workbook. We have a section of the VBA that will take a sheet from the .XLSM file and save it to the C:\ drive as a .CSV, this works fine.
I am trying to modify it to save it as a .XLSX file. I can get the file to save down, but cannot open it getting the "incorrect file path" type error.
Here is the code
Sub MakeCSV()
Dim Portfolio As String, Qtr As String, Year As String, xlNormalFileName As String
ActiveWorkbook.Sheets("Submission").Select
Range("A2").Select
Portfolio = Range("A2").Value
Year = ActiveCell.Offset(A2, 1)
Qtr = ActiveCell.Offset(A2, 2)
ActiveWorkbook.Sheets("Submission").Select
'Export to XLSX File
xlNormalFileName = Portfolio & "_" & Year & Qtr & "_XLS_Data.xlsx"
ExportToxlNormalFile FName:="C:\NCREIF EXPORT\" & xlNormalFileName, Sep:=",", SelectionOnly:=False, AppendData:=False
MsgBox "XLSX File: " & xlNormalFileName & " created."
End Sub
I changed the values to xlNormalFileName, based on some searching I did and I feel like the issue is realted. I have found where you can specify the file format FileFormat:= 50 (etc), but I get erros with that. Your help is appreicated!
I have searched for this but cannot find a suitable answer. I have been tasked with modifying a coworkers workbook. We have a section of the VBA that will take a sheet from the .XLSM file and save it to the C:\ drive as a .CSV, this works fine.
I am trying to modify it to save it as a .XLSX file. I can get the file to save down, but cannot open it getting the "incorrect file path" type error.
Here is the code
Sub MakeCSV()
Dim Portfolio As String, Qtr As String, Year As String, xlNormalFileName As String
ActiveWorkbook.Sheets("Submission").Select
Range("A2").Select
Portfolio = Range("A2").Value
Year = ActiveCell.Offset(A2, 1)
Qtr = ActiveCell.Offset(A2, 2)
ActiveWorkbook.Sheets("Submission").Select
'Export to XLSX File
xlNormalFileName = Portfolio & "_" & Year & Qtr & "_XLS_Data.xlsx"
ExportToxlNormalFile FName:="C:\NCREIF EXPORT\" & xlNormalFileName, Sep:=",", SelectionOnly:=False, AppendData:=False
MsgBox "XLSX File: " & xlNormalFileName & " created."
End Sub
I changed the values to xlNormalFileName, based on some searching I did and I feel like the issue is realted. I have found where you can specify the file format FileFormat:= 50 (etc), but I get erros with that. Your help is appreicated!