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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Jon von der Heyden

MrExcel MVP, Moderator
Joined
Apr 6, 2004
Messages
10,810
Office Version
  1. 365
Platform
  1. Windows
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
:)
 

joefrench

Active Member
Joined
Oct 4, 2006
Messages
357
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.
 

Forum statistics

Threads
1,141,754
Messages
5,708,317
Members
421,564
Latest member
Ian_20210927

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
Top