I created a simple macro to publish a range of cells to a directory as an htm file. The macro works perfectly when running it directly from the VBA editor.
I created a button to run the macro from the worksheet. The button simply calls the publishing macro. The problem is, the macro doesn't work when called from the button. I get an "Method 'Publish' of object 'PublishObject' failed" error (Error # 1004).
After getting this error, the macro will not work when running directly in the editor again unless I manually republish the range.
Any thoughts? this is driving me nuts. Code below:
I created a button to run the macro from the worksheet. The button simply calls the publishing macro. The problem is, the macro doesn't work when called from the button. I get an "Method 'Publish' of object 'PublishObject' failed" error (Error # 1004).
After getting this error, the macro will not work when running directly in the editor again unless I manually republish the range.
Any thoughts? this is driving me nuts. Code below:
Sub Publish_Range()
Dim rngSend As Range
Const htmlFile As String = "c:\temp.htm"
Set rngSend = Worksheets("Carry").Range("B22").CurrentRegion
With ActiveWorkbook.PublishObjects.Add(SourceType:=xlSourceRange, _
Filename:=htmlFile, _
Sheet:="Carry", _
Source:=rngSend.Address, _
HtmlType:=xlHtmlStatic)
.Publish (True)
End With
End sub
