batch 'save as' html to xls

Hi all,

I have registered to this forum mainly because I have an issue which I cannot get sorted.

I use CMS Scripts from Avaya for export a file which is saved as .xls, but in fact it is a HTML file.

I use these reports to extract daily information which then populate another file which has the monthly data.

My issue is that because the file which is generated by the script is not in 'real' .xls format, when the formulas in the monthly file try to populate the fields, no information is found.

Because of this I need to open the daily file, one by one and to a 'Save as' action to 97/03 Excel format.

What I would like to find is a way, either a Macro or another tool which would allow me to save all daily files in a batch into .xls format, without having to open them individually.

Can anyone help me with this?

Thank you for any assistance provided.
Pedro

Thanks Manny, I will try this

Thanks Manny,
I will try this out and will let you know if it worked.
Pedro

Automate 'Save As' action

Hi,

I can suggest some subroutine to automate your Save As task. Before use it note the following:

 1) Put the subroutine into the standard code module.

 2) Go to in VBE menu Tools -> References..., check Microsoft Scripting Runtime if not.

 3) When run the macro a dialog window will open to browse and select a folder which contain the files you want to resave. Afterwards, another dialog window will open to select a folder in which the files to be resaved. You can select the same folder in both dialog windows but this will replace any existing file without prompt you with the new one.

Here's the subroutine:

' ************************* ' ************************ '

Sub ReSaveXlsFiles()

    Dim strTargetFolderPath As String
    Dim strDestinationFolderPath As String
    Dim oFSO As FileSystemObject
    Dim oFolder As Folder
    Dim oFile As File
    Dim oWbk As Workbook
    Dim intCounter As Integer
    Dim strPrompt As String
    Dim strTitle As String

   
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

   
    On Error GoTo ERROR_HANDLER
   
    With Application.FileDialog(msoFileDialogFolderPicker)
        .Title = "Target Folder"

       
        If .Show = -1 Then
            strTargetFolderPath = .SelectedItems(1)

           
            With Application.FileDialog(msoFileDialogFolderPicker)
                .Title = "Destination Folder"

               
                If .Show = -1 Then
                    strDestinationFolderPath = .SelectedItems(1)

                   
                    Set oFSO = New FileSystemObject
                    Set oFolder = oFSO.GetFolder( _
                        FolderPath:=strTargetFolderPath)

                   
                    For Each oFile In oFolder.Files
                        With oFile
                            If Right(.Name, 4) = ".xls" Then
                                Set oWbk = Workbooks.Open( _
                                    Filename:=.Path)

                               
                                With oWbk
                                    .SaveAs _
                                        Filename:=strDestinationFolderPath & "\" & .Name, _
                                        FileFormat:=xlExcel8
                                    .Saved = True
                                    .Close
                                End With

                               
                                intCounter = intCounter + 1
                            End If
                        End With
                    Next oFile
                End If
            End With
        End If
    End With

   
EXIT_SUB:
    strPrompt = "Number of resaved file(s): " & intCounter & vbCrLf & _
        "From: " & strTargetFolderPath & vbCrLf & _
        "To: " & strDestinationFolderPath
    strTitle = "Resaved file(s)"

   
    MsgBox Prompt:=strPrompt, Title:=strTitle
   
    Set oWbk = Nothing
    Set oFile = Nothing
    Set oFolder = Nothing
    Set oFSO = Nothing

   
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    Exit Sub

   
ERROR_HANDLER:
    ' Some code for error handling
    Err.Clear
    Resume EXIT_SUB

End Sub

' ************************* ' ************************ '

 

If there is something else - ask.

 

Best regards.

Automate 'Save As' action

Thanks a lot Manny. It worked to perfection!

Happy New Year

Pedro