+ Reply to Thread
Results 1 to 4 of 4

Open > Click Ok on Error > Save as .xlsm

Hybrid View

  1. #1
    Registered User
    Join Date
    05-26-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    65

    Open > Click Ok on Error > Save as .xlsm

    All,

    I have about 51k .xls files that I converted from HTML. When I open one, I get the following error: File Error: data may have been lost

    I need a macro that will open all the .xls books in C:/BoxScoreTest, bypass that error, and save as .xlsm. Is that possible?

    Thanks in advance

  2. #2
    Registered User
    Join Date
    05-26-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    65

    Re: Open > Click Ok on Error > Save as .xlsm

    Hey all, I got it. Thanks!

  3. #3
    Registered User
    Join Date
    05-26-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    65

    Re: Open > Click Ok on Error > Save as .xlsm

    Hey all, I was wrong. The macro was working on some files but not others.

    This is my macro I'm running to open the xls, make some modifications, close and save the xls. However, I'm getting a failure and the macro won't run on 99% of the xls sheets. I think its because they were converted from HTML into xls. Is there a way to tell my code when trying to open a sheet, if you get an error click ok, and then execute macro?
    Sub New_Clean()
    '
    ' Macro2 Macro
    '
    Dim PathName As String
    Dim FileName As String
    Dim CurrentWB As Workbook
    Dim Pic As Object
    
    PathName = "C:\BoxScoreTest\"
    FileName = Dir(PathName & "*.xls")
    Do While FileName <> ""
      Set CurrentWB = Workbooks.Open(PathName & FileName)
      With CurrentWB.ActiveSheet
        .Rows("1:30").Delete Shift:=xlUp
        With .UsedRange.Font
          .Name = "Verdana"
          .Size = 10
          .Strikethrough = False
          .Superscript = False
          .Subscript = False
          .OutlineFont = False
          .Shadow = False
          .TintAndShade = 0
          .ThemeFont = xlThemeFontNone
          .ColorIndex = xlAutomatic
          
          
    For Each Pic In ActiveSheet.Pictures
    Pic.Delete
    Next Pic
          
        ActiveWindow.SmallScroll Down:=-120
        Range("A1:BR500").Select
        Selection.SpecialCells(xlCellTypeBlanks).Select
        Selection.Delete Shift:=xlToLeft
     
        Columns("I:BX").Select
        Selection.Delete Shift:=xlToLeft
        
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    
        End With
        End With
    CurrentWB.Close True
    FileName = Dir()
    
    Loop
    End Sub

  4. #4
    Registered User
    Join Date
    05-26-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    65

    Re: Open > Click Ok on Error > Save as .xlsm

    No responses here. had to buy a converter.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA code to 'click' Open in the Open or Save dialogue box on a webpage?
    By bensox in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-31-2012, 05:40 AM
  2. Replies: 2
    Last Post: 08-13-2012, 05:20 PM
  3. [SOLVED] Click button to save as file name --> open message if range is 1
    By debbiesh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-04-2012, 03:05 PM
  4. Open Multiple Files to Update - Close & Save with One click
    By awaken88 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-13-2012, 05:24 PM
  5. Line Print setting Error when trying to save xls as .xlsm
    By jambai in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2011, 03:15 PM

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