Need help with FP Object Model using VBScript

D

DontEvenBother

I've been trying to use WSH with VBScript to automate the publishing of
FP 2000, but to no avail. I have looked at 2 available examples, but
am still having trouble.

I first tried an MSDN example by Jimco:
http://msdn.microsoft.com/library/d...n-us/dnfp2k2/html/odc_fppublishingwithvba.asp

But it's written for FP 2002/2003 and isn't working for me in 2000.
FWIS, here are the errors it produces:

Dim pw As PageWindowEx => User-defined type not defined.
I then changed it to just PageWindow (FP2K syntax?) and got no errror,
but still getting this next error...

boolPublishResult = PublishWeb(txtDestination.Text, fpPublishFlags) =>
Compile Error: Sub or function not defined.
If I removed the parens as the FP2K syntax would suggest, I get
"Compile Error: Expected end of statement." I gave up on this example,
but hopefully learned a little.

*The second Script I found was written to work as a VBA macro within FP
and does work in that environment:

Sub PublishActiveWeb
Dim myWeb, sDestWebURL, sUser, sPassword

Set myWeb = Application.ActiveWeb
sDestWebURL = "http://mywebsite.com"
sUser = "myusername"
sPassword = "mypassword"
myWeb.publish sDestWebURL, fpPublishAddToExistingWeb +
fpPublishIncremental, sUser, sPassword
End sub

** So with a little culling and some tweaking, like creating the FP
Application object and opening the source web first, I arrived at the
following:

Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")

Dim sSourceWeb, sDestWeb, sUser, sPassword

Dim oMyWeb
Set oMyWeb = WScript.CreateObject("FrontPage.Application")

sSourceWeb = "http://LocalWeb"
sDestWeb = "http://www.mywebsite.com"
sUser = "myusername"
sPassword = "mypassword"

oMyWeb.Webs.Open(sSourceWeb)
oMyWeb.ActiveWeb.Publish sDestWeb,fpPublishAddToExistingWeb +
fpPublishIncremental,sUser,sPassword
oMyWeb.ActiveWebWindow.Close

The resulting error:
Line: 18 (the oMyWeb.Publish line)
Char: 1
Error: Bad Parameter passed to Web Server Extensions. Check the
information you entered and try again
Code: 80004005

Could someone please tell me where I am going wrong? The docs on the
FP Object Model for FP2K are slim & confusing, and making the changes
from VBA to VBScript may also be eluding me.

Thanks,
Jim
 
J

Jim

Here's a change to the code that makes it work, and at least a partial
explanation as to why.

Add the following:
Dim fpPubFlags
fpPubFlags=3 ' fpPublishIncremental + fpPublishToExistingWeb

Change 2nd to last line as follows:
oMyWeb.ActiveWeb.Publish sDestWeb,fpPubFlags,sUser,sPassword

VBScript doesn't support strong typing, thus Dim fpPublishFlags As
FpWebPublishFlags, a common line in many VBA examples I found, throws
an "expected end of statement" error in VBScript.

Now, I don't know if trimming the declaration of variables down for
VBScript (i.e. Dim fpPublishFlags) is the culprit or if instantiating
the FrontPage.Application object in VBScript is insufficient to make
use of the fpWebPublishFlags enumerated constants
(fpPublishIncremental, fpPublishToExistingWeb, fpPublishNone,
fpPublishCopySubwebs.)

I just know that from my trial and error, the constants were not being
recognized (possibly being passed as null) and that a variable set to
the total (or a hard coded number) passed in the ActiveWeb.Publish
method works in VBScript and the built-in FP constants do not (at least
as illustrated in the provided sample code here).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top