PDA

View Full Version : Solved: PublishObjects



cactus
01-11-2008, 07:43 AM
I have a problem. I want to publish several ranges in a sheet with this code:
-----------------------------------------------------------------------
For I = 5 To 34
Dim objpubl As PublishObject
If Sheets("PROD").Range(Range("DD" & I).Value).Value <> "(ALL)" Then
Set objpubl = Workbooks("prod.xls").PublishObjects.Add _
(SourceType:=xlSourceRange, _
Filename:="*webserver\" & Range(Range("DD" & I).Value).Value & ".htm", _
Sheet:="PROD", _
Source:=Range(Range("DD" & I).Value).Offset(0, -1) & ":" & Range(Range("DD" & I).Value).Offset(27, 18), _
HtmlType:=xlHtmlStatic, _
DivID:="Sample")
objpubl.Publish
Else
End If

Next

-----------------------------------------------------------------------
but I have an "Application-defined or object-defined error". I think the trouble is in the source: I have the the range names in the column "DD"



Thanks in advance and sorry for my english.

Cactus.-

Bob Phillips
01-11-2008, 12:34 PM
Range("DD" & I) will be referring to the activesheet, which may not be the sheet you think it is. Explicitly prefix it with the appropriate worksheet object.

cactus
01-12-2008, 04:12 AM
Thanks for your answer El Xid, but still doesn't work.

Any suggestion?

Bob Phillips
01-12-2008, 10:18 AM
Source is resolving to TL:0, which is not a valid range, and Excel 2003 doesn't have a DIVId argument.

cactus
01-12-2008, 02:02 PM
Thanks for your answer, I really appreciate you help; but this is the diagnosis and my problem is with the solution... I really don't know how to resolve this problem!!

Bob Phillips
01-12-2008, 02:46 PM
Well only you can resolve it, not me, you wrote the code. The Source resolves incorrectly, so what should it really be, and why have you added an argument that isn't valid.