Results 1 to 8 of 8

Macro Saving As Unopenable "File"

Threaded View

jhuang5132 Macro Saving As Unopenable... 08-06-2014, 05:08 PM
Paul Re: Macro Saving As... 08-06-2014, 05:45 PM
alansidman Re: Macro Saving As... 08-06-2014, 05:46 PM
TMS Re: Macro Saving As... 08-06-2014, 06:06 PM
jhuang5132 Re: Macro Saving As... 08-07-2014, 10:34 AM
jhuang5132 Re: Macro Saving As... 08-17-2014, 11:59 PM
alansidman Re: Macro Saving As... 08-18-2014, 09:09 AM
jhuang5132 Re: Macro Saving As... 08-18-2014, 11:21 AM
  1. #1
    Registered User
    Join Date
    04-25-2014
    Location
    NYC, NY
    MS-Off Ver
    Excel 2010
    Posts
    44

    Macro Saving As Unopenable "File"

    For some reason, my macro doesn't save my file as an xlxs and instead just shows up as "File" which is unopenable. I've done some troubleshooting so hopefully someone can help me figure it out. The code in question is below.

    
    Sub reverseandsave()
    
        Rows("1:1").Select
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        Rows("3:3").Select
        Selection.Cut
        Rows("1:1").Select
        ActiveSheet.Paste
        Rows("3:3").Select
        Selection.Delete Shift:=xlUp
    
           '
    
        Range("A3:B3").Select
        Selection.Copy
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    
           '
    
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .PrintTitleRows = "$1:$4"
            .PrintTitleColumns = ""
        End With
        Application.PrintCommunication = True
    
           '
    
        ThisFile = Range("A1").Value
        ActiveWorkbook.SaveAs Filename:=ThisFile, FileFormat:=51
    
    End Sub
    I tried troubleshooting by removing the three pieces of individual code above, but it all gave my the unreadable file.

    The two main things I want are: Reverse order of A1 and A2 in file, and then save as .xlxs using value in A1.

    OLD A1: typically something like "AB1-41242-R2402"
    OLD A2: typically something like "Company Car, Ltd."

    NEW A1: typically something like "Company Car, Ltd."
    NEW A2: typically something like "AB1-41242-R2402"

    Both A1 and A2 are saved as text. Sometimes when I run the code and set it to take the value of A2 instead of A1, it appears correctly. I'm not sure if it's because the NEW A2 more closely resembles a value.

    If I run this code by itself, it saves properly as .xlxs (BEFORE THE REVERSAL OF A1 and A2). The size of the unopenable file is the same as the .xlxs file when it works, so I'm assuming something with the converting is going wrong.

    
        ThisFile = Range("A1").Value 
        ActiveWorkbook.SaveAs Filename:=ThisFile, FileFormat:=51
    If anyone can help, that would be great. Thanks in advance.

    Edit: The second part of the code where I copy and paste is for the =now() function. I paste the values so it saves as text and doesn't change every time.
    Last edited by jhuang5132; 08-06-2014 at 05:13 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Stop Users Saving Macro Enabled File as ".xlsx"
    By OzTrekker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2012, 11:33 PM
  2. Replies: 0
    Last Post: 11-16-2011, 01:35 PM
  3. Replies: 4
    Last Post: 07-15-2011, 11:50 AM
  4. Transfert cell values from file "A" to file "B" skipping columns in file "B".
    By Sentrosi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2009, 11:11 PM
  5. Saving a file to a "YYYY" and "MMM" folder
    By hriggs in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-10-2008, 07:00 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1