Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with PublishObjects in Excel

Status
Not open for further replies.

pacome

Programmer
Feb 19, 2002
2
FR
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 = &quot;0&quot; & R
Else
N = &quot;&quot; & R
End If
IndexPays = Mid(NomFichier, 4, 2)
CeFichier = Dossier & &quot;\&quot; & &quot;f&quot; & N & IndexPays & &quot;.htm&quot;
Set LaPlage = ActiveSheet.Range(DebutPlage & &quot;:&quot; & FinPlage)


Excel.ActiveWorkbook.PublishObjects.Add( _
xlSourceRange, _
CeFichier, _
ActiveSheet, _
LaPlage, _
xlHtmlStatic).Publish (True)


End Sub
 
Answer found!

(...)

IndexPays = Mid(NomFichier, 4, 2)
Identificateur = IndexRang & IndexPays
CeFichier = Dossier & &quot;\&quot; & &quot;f&quot; & N & IndexPays & &quot;.htm&quot;
Set LaPlage = ActiveSheet.Range(DebutPlage & &quot;:&quot; & FinPlage)
LesCoordonnees = LaPlage.Address


Dim Publier As PublishObject
Set Publier = ActiveWorkbook.PublishObjects.Add(xlSourceRange, CeFichier, ActiveSheet.Name, _
LesCoordonnees, xlHtmlStatic, &quot;&quot;, &quot;&quot;)

Publier.Publish (False)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top