Consulting

Results 1 to 6 of 6

Thread: Help with FileFormat issue

  1. #1
    VBAX Newbie
    Joined
    May 2017
    Posts
    3
    Location

    Unhappy Help with FileFormat issue

    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:=
    compileerror.JPG

    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.

    TIA

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    It seems that .SaveCopyAs does not have the same arguments as .SaveAs.
    It appears only to have one argument, the filename.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    ... and you can only save a single sheet workbook as a csv.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    A copy is a copy: so a copy of an .xlsb file is an .xlsb file and not a csv-file, nor anything else.

  5. #5
    VBAX Newbie
    Joined
    May 2017
    Posts
    3
    Location
    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.

  6. #6
    VBAX Newbie
    Joined
    May 2017
    Posts
    3
    Location
    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •