Macro not working after updating Excel

Cazforshort

New member
Joined
Sep 3, 2015
Messages
4
Reaction score
0
Points
0
Hello, I had a macro that makes use of an HTLM document. After my company updated its excel application, the program no longer works.

Any idea why this might be?
 
Here is the code that seems to be doing the importing. It prompts to pick a HTML file then says Import failed. It worked in Excel 2003.
Pardon the French.

Nom du fichier de destination (en cas de copie, nouveau nom, etc.) (pas conservé depuis la routine ci-dessus)
Fichier_destination = ActiveWorkbook.Name

'Récupération du chemin du répertoire-mère
Reponse = Application.Dialogs(xlDialogFindFile).Show
If Reponse = False Then
ActiveSheet.Range("A1").Select
Application.ScreenUpdating = True
Exit Function
End If
Repertoire_source = ActiveWorkbook.Path
Repertoire_file = ActiveWorkbook.Name
ActiveWorkbook.Close SaveChanges:=False
Application.ScreenUpdating = True
Application.ScreenUpdating = False

'Recherche des fichiers htm(l) dans son arborescence (pas dans les sous-dossiers, sinon l'adresse n'est plus correcte)
With Application.FileSearch
.NewSearch
.LookIn = Repertoire_source
.SearchSubFolders = False
.Filename = Repertoire_file
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
'Code à appliquer si des fichiers ont été trouvés
If .Execute > 0 Then
'Initialisation des variables (autres : fait en cours de calcul)
FichierFSR = 0
Numero_scenario = 1
Numero_label = 1
Destination_Y = 1
Destination_Y2 = 1 'liste des noeuds
ActiveSheet.Unprotect

Cells.Select
Selection.EntireColumn.Hidden = False

'Pour chaque fichier trouvé (n° arbitraire attribué par Excel à l'ouverture)
For Numero_fichier = 1 To .FoundFiles.Count
'caca - newLD
skip_intro = 0
'fin caca - newLD
'Ouverture du fichier depuis Excel
Fichier_source = Right(.FoundFiles(Numero_fichier), Len(.FoundFiles(Numero_fichier)) - Len(Repertoire_source) - 1)
Workbooks.Open Filename:=Repertoire_source & "\" & Fichier_source
'Tant qu'il y a au-moins un fichier html ouvert sous Excel
If Workbooks.Count > 1 Then
'Recherche de la dernière ligne du fichier
Workbooks(Fichier_source).Sheets(1).Activate
ActiveSheet.Range("B65536").Select
Selection.End(xlUp).Select
Lignes_fichier = ActiveCell.Row
'On défusionne les cellules (sinon, problèmes dans les références des cellules, par ex. avec "Offset")
Workbooks(Fichier_source).Sheets(1).Cells.Select
With Selection
.MergeCells = False
End With
'Récupération du nom du fichier à la suite du précédent ("Offset" de la cellules de destination traité à part, pour faciliter un changement de présentation côté html ou côté Excel)
Destination_X = 1
'Pas de décalage de ligne dans le tableau de destination : déjà incrémenté en sortie du traitement du fichier
'Nom sans extension, or l'extension peut être "htm" ou "html"
If Right(Left(Fichier_source, Len(Fichier_source) - 4), 1) = "." Then
Workbooks(Fichier_destination).Sheets("Summary").Range("B4").Offset(Destination_Y, Destination_X) = Left(Fichier_source, Len(Fichier_source) - 5)
Else
Workbooks(Fichier_destination).Sheets("Summary").Range("B4").Offset(Destination_Y, Destination_X) = Left(Fichier_source, Len(Fichier_source) - 4)
End If
 
Svp utilisez les 'Code tags'.

Filesearch has been removed from VBA.
 
Svp utilisez les 'Code tags'.

Filesearch has been removed from VBA.

Oh, That's not good. Why did they remove that? Does this mean I cant fix it? Seems like file search was a pretty vital part of how this code operates.

Thanks,
Caz
 
Please do not quote !

If you happen to meet Bill you can ask him. He is avoiding me lately.
You will have to use another method: i.e rewrite the entire code.
 
To catch all html files in directory "G:\OF\" (just an example)

Code:
Sub M_snb()
  sn=filter(split(createobject("wscript.shell").exec("cmd /c Dir ""G:\OF\*.html"" /b").stdout.readall,vbcrlf),".")

  for j=0 to ubound(sn)
    msgbox "G:\OF\" & sn(j)
  next
End Sub
 
Hi Caz

Google on application.filesearch replacement...you'll get many hits.
 
Back
Top