Problem ublishing after running a save as macro

joefrench

Active Member
Joined
Oct 4, 2006
Messages
357
I have a workbook that will be acting as a "template". Upon an action, I have the file doing a save as. After the save as, I need to have the workbook publish a static html file. I cannot seem to get the code to do this.

This is what I have but I keep getting errors:
Code:
Sub publish()
'
' publish Macro
' Macro recorded 10/10/2006 by Joe French

Dim strDir As String

strDir = "\\Cjdata1\design engineering common\Molds\" & Sheet2.Range("O1").Value & "\" & Sheet1.Range("J4").Value & "\Router\"
'

    With ActiveWorkbook.PublishObjects("A-062_3870")
        .Title = Sheet1.Range("J4").Value & "Router"
        .Filename = strDir & Sheet1.Range("J4").Value & ".htm"
        .publish (True)
    End With

End Sub

"A-062" is the "template" files name. The save as is being performed prior to the publishing. Is this where my problem is?[/code]
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
should it be:

Code:
Sub publish() 
' 
' publish Macro 
' Macro recorded 10/10/2006 by Joe French 

Dim strDir As String 

strDir = "\\Cjdata1\design engineering common\Molds\" & Sheets("Sheet2").Range("O1").Value & "\" & Sheets("Sheet1").Range("J4").Value & "\Router\" 
' 

    With ActiveWorkbook.PublishObjects("A-062_3870") 
        .Title = Sheets("Sheet1").Range("J4").Value & "Router" 
        .Filename = strDir & Sheets("Sheet1").Range("J4").Value & ".htm" 
        .publish (True) 
    End With 

End Sub

What error are you getting? And at what line?

Cheers
Jon
:)
 
Upvote 0
I'm afraid not.

It is giving me a Run-time error '1004':
Method 'Publish' of object 'PublishObject' failed

When I choose "Debug", VB highlights the .publish (True) portion of the code. Same error I was receiving before.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top