Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default PublishObject.Publish Error

I've written a routine to republish previously published ranges in an Excel
workbook as web pages. Basically, it changes the filename of the webpage to
use the current date:

Private Sub ExportHTML(ByVal dateEffective As Date)
Dim objPubOb As PublishObject
Dim strDate As String

strDate = Format$(dateEffective, "ddmmyy")

For Each objPubOb In ThisWorkbook.PublishObjects
With objPubOb
If .SourceType = xlSourceRange Then
.HtmlType = xlHtmlStatic
.Filename = Left(.Filename, Len(.Filename) - 10) & strDate &
".htm"
.Publish (True)
End If

End With

Next objPubOb

End Sub

This throws up a run-time error 1004: Method 'Publish' of object
'PublishObject' failed. Weirdly, if I debug, it then works. I've tried
trapping the error and calling the Publish method again, but that doesn't
work either.

I know I could create new PublishObjects, but they would have different
DivID numbers, which I would like to avoid.

Any suggestions would be much appreciated.

Adam
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default PublishObject.Publish Error


In case anyone else comes across this problem, I found a solution -
activating the sheet containing the range to be published:

Private Sub ExportHTML(ByVal dateEffective As Date)
Dim objPubOb As PublishObject
Dim strDate As String

strDate = Format$(dateEffective, "ddmmyy")

For Each objPubOb In ThisWorkbook.PublishObjects
With objPubOb
If .SourceType = xlSourceRange Then
.HtmlType = xlHtmlStatic
.Filename = Left(.Filename, Len(.Filename) - 10) & strDate &
".htm"
ThisWorkbook.Names(.Source).RefersToRange.Parent.A ctivate

.Publish (True)
End If

End With

Next objPubOb

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
publish as web page Hostohio Excel Discussion (Misc queries) 0 January 12th 10 06:47 PM
Publish as Wed Page JDH Setting up and Configuration of Excel 0 April 1st 08 03:21 PM
publish iwinlof Excel Discussion (Misc queries) 0 March 23rd 06 10:59 PM
publish to web G. Beard New Users to Excel 0 October 3rd 05 06:02 PM
How to publish VBA and UserForms on the web? MichelleDuquette Excel Programming 0 March 14th 05 03:17 AM


All times are GMT +1. The time now is 04:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"