Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 8th, 2004, 03:17 AM
Registered User
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default PublishObjects give Error 1004

I have been trying to write a routine to publish and update worksheet data on a web page on our company Intranet. I used the macro recorder to create a code fragment to achieve this (see below).

    With ActiveWorkbook.PublishObjects.Add(xlSourcePrintAre a, _
        "I:\General\01 Euro 2004 Sweepstake - Latest Positions.htm", "Positions", "", xlHtmlStatic, "Euro 2004_14332", _
        .Publish (True)
        .AutoRepublish = False
    End With

This works fine when run from the normal macro menu. I wanted to include a button with an Active x control on the actual sheet that could run the code. I inserted the routine call in the Button_Click event but when the publish routine runs it stops at the .Publish line with Error 1004. I have tried pasting the Publish code directly into the event handler but nothing makes any difference.

Could someone tell me what I am doing wrong?
Old June 16th, 2004, 03:08 AM
Authorized User
Join Date: Jun 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts

This may sound a little strange, but I've run into similar difficulties in the past myself.

I believe that the problem you're having here is that your Button_Click event is specific to the page in which you've written the code. Create a module and put the code in there, and use the Button_Click event to call the sub from the module - this should solve your problem.

Hope that helps, if not I'll try to clarify with an example or something.

Ne auderis delere orbem rigidum meum!

Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Web Query Generating Error 1004 bob135 Excel VBA 1 May 28th, 2009 07:31 PM
Run time error 1004 Ken Matthews Excel VBA 1 March 2nd, 2007 06:30 AM
Run-time error '1004' Document not saved Tucky Excel VBA 0 October 28th, 2004 12:04 AM
Run-time error '1004': raja.gogoi VB Components 1 July 18th, 2004 11:02 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.