PDA

View Full Version : Help with FileFormat issue



kelisaid
05-25-2017, 08:48 AM
Hi All!

I'm fairly new to VBA and am attempting to just save my file as a csv. Basically I have a workbook that is connected to an XML feed so it updates when I need it to. When I refresh the doc I call my program substitution function(which just does a loop through a column and changes values to something I can import in our CRM so there are matching values). After this is completed, I'd like for the new results to be automatically saved to a csv file for import.

This is the code I currently have set up:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.DisplayAlerts = False
Call ProgramSubstitutions
ActiveWorkbook.SaveCopyAs Filename:="G:\Enroll_Dev\ADMISSIONS AND RECRUITMENT ACTIVITIES\Admissions\Keystone\internationalimports.csv", FileFormat:=xlCSV
End Sub

However everytime I run it I'm getting this error: Compile Error: Named Argument not Found and it's highlighting the FileFormat:=
19286

Ugh what am I doing wrong? I'm assuming it's something super simple and I have looked and looked to see what may be happening but I can't find a solution. :hairpull:

TIA

p45cal
05-25-2017, 10:42 AM
It seems that .SaveCopyAs does not have the same arguments as .SaveAs.
It appears only to have one argument, the filename.

mdmackillop
05-25-2017, 10:58 AM
... and you can only save a single sheet workbook as a csv.

snb
05-25-2017, 11:49 AM
A copy is a copy: so a copy of an .xlsb file is an .xlsb file and not a csv-file, nor anything else.

kelisaid
05-25-2017, 12:48 PM
Thanks everyone for your input. The reason for using the savecopyas was preventing the original file from closing so I could keep the workbook open (not convert to csv). Now I understand that's not how it works. Is there another way to do this? Save the file as a csv but keep the workbook open? I suppose like exporting the file as CSV.

kelisaid
05-25-2017, 12:57 PM
Thank you!