Excel VBA Exporitng to .XLSX

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!
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Watch MrExcel Video

Forum statistics

Threads
1,123,329
Messages
5,600,996
Members
414,419
Latest member
JRDunya

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
Top