I wrote 4 Subs to find specific ranges of data in excel charts and save them as HTML files. The first part, the finding, works well but when it comes to save... I get a 1004 error : Error defined by application or project (translated from french)in my PublishObject.Add function.
I tried several ways to write this instruction...but 1004 again whatever I try...
Any ideas? Code follows
(DebutPlage and FinPlage are ranges defined in the 'Finding' Sub)
Sub SauvePlage()
Dim LaPlage As Range
Dim CeFichier As String
Dim N As String 'N, c'est le numéro d'index des indicateurs (R) converti en chaîne
Dim IndexRang As Long 'Les deux chiffres correspondant à l'index du pays concerné
IndexRang = Range(FinPlage).Row
FinPlage = "H" & IndexRang
If R < 10 Then 'Là c'est pour formater N en xx par ex:03 ou 11
N = "0" & R
Else
N = "" & R
End If
IndexPays = Mid(NomFichier, 4, 2)
CeFichier = Dossier & "\" & "f" & N & IndexPays & ".htm"
Set LaPlage = ActiveSheet.Range(DebutPlage & ":" & FinPlage)
Excel.ActiveWorkbook.PublishObjects.Add( _
xlSourceRange, _
CeFichier, _
ActiveSheet, _
LaPlage, _
xlHtmlStatic).Publish (True)
End Sub
I tried several ways to write this instruction...but 1004 again whatever I try...
Any ideas? Code follows
(DebutPlage and FinPlage are ranges defined in the 'Finding' Sub)
Sub SauvePlage()
Dim LaPlage As Range
Dim CeFichier As String
Dim N As String 'N, c'est le numéro d'index des indicateurs (R) converti en chaîne
Dim IndexRang As Long 'Les deux chiffres correspondant à l'index du pays concerné
IndexRang = Range(FinPlage).Row
FinPlage = "H" & IndexRang
If R < 10 Then 'Là c'est pour formater N en xx par ex:03 ou 11
N = "0" & R
Else
N = "" & R
End If
IndexPays = Mid(NomFichier, 4, 2)
CeFichier = Dossier & "\" & "f" & N & IndexPays & ".htm"
Set LaPlage = ActiveSheet.Range(DebutPlage & ":" & FinPlage)
Excel.ActiveWorkbook.PublishObjects.Add( _
xlSourceRange, _
CeFichier, _
ActiveSheet, _
LaPlage, _
xlHtmlStatic).Publish (True)
End Sub