Results 1 to 6 of 6

Thread: Saving file with non standard extension
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Nov 2008
    Posts
    131
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Saving file with non standard extension

    We have a system that creates files that are imported into Oracle. The files have the naming convention...
    Filename.0000
    ... where the numbers are incremented with each export. So one file might be filename.4357 and the next file will be filename.4358 and so on.
    Ive managed to import the file into a spreadsheet as a comma delimited file where I then carry out some cleansing of the file using VBA.
    I then want to save the file back to this unusual type .0000 but I can only seem to save it as Excel, CSV, TXT, PDF etc.
    Does anyone have any ideas ? Thank you in advance.

  2. #2
    Board Regular
    Join Date
    Apr 2010
    Posts
    167
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Saving file with non standard extension

    Quote Originally Posted by music_al View Post
    We have a system that creates files that are imported into Oracle. The files have the naming convention...
    Filename.0000
    ... where the numbers are incremented with each export. So one file might be filename.4357 and the next file will be filename.4358 and so on.
    Ive managed to import the file into a spreadsheet as a comma delimited file where I then carry out some cleansing of the file using VBA.
    I then want to save the file back to this unusual type .0000 but I can only seem to save it as Excel, CSV, TXT, PDF etc.
    Does anyone have any ideas ? Thank you in advance.

    Code:
          ThisWorkbook.SaveAs "c:\test.0000"

  3. #3
    Board Regular
    Join Date
    Nov 2008
    Posts
    131
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Saving file with non standard extension

    Thanks Steve. That sort of works but it seems to do something crazy with the contents of the file.

    The original file opens like a CSV file but the resulting file after doing the SaveAs has random character in it.

  4. #4
    Board Regular
    Join Date
    Apr 2010
    Posts
    167
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Saving file with non standard extension

    Quote Originally Posted by music_al View Post
    Thanks Steve. That sort of works but it seems to do something crazy with the contents of the file.

    The original file opens like a CSV file but the resulting file after doing the SaveAs has random character in it.
    I have been messing around with this a bit. The only way to get it to work so far has been for me to save it in CSV format, and then afterwards, rename the file to strip the file extension from it.

  5. #5
    Board Regular
    Join Date
    Nov 2008
    Posts
    131
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Saving file with non standard extension

    I cant get it to work. It still messes up the file to just very random characters.

  6. #6
    Board Regular
    Join Date
    Nov 2008
    Posts
    131
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Saving file with non standard extension

    I want to close the file and then use the NAME function to change its name by removing the .txt from the end. I'm getting a subscript out of range error on the highlighted line.

    Code:
    Sub SaveAs_ARIS_File()
    
    
        Dim Original_Filename As String, New_Filename As String
        Original_Filename = Worksheets("Sheet1").Range("A1")
        Application.DisplayAlerts = False    'Turn off display alerts
        
        Sheets("ARIS Upload File (4145)").Select
        Sheets("ARIS Upload File (4145)").Move
        ActiveWorkbook.SaveAs Filename:=Original_Filename & ".txt", FileFormat:=xlText, CreateBackup:=False
        
        New_Filename = Original_Filename & ".txt"
        
        'I get an error on this line - Subscript out of range
        Workbooks(New_Filename).Close SaveChanges:=False
        
        Application.DisplayAlerts = True    'Turn off display alerts
        
    End Sub
    Last edited by music_al; Aug 11th, 2019 at 01:23 PM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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