FrontPage Publishing with Visual Basic for Applications

M

Mossier

Dear Readers,

I have a question about scheduling the publishing task in Frontpage. I
already had a question in the newsgroup frontpage.client. David Berry pointed
me out to use VBA, and he gave me an simple example in VBA. I am searching
for other examples in VBScript with more error handling. I then can use
VBScript to schedule the publishing task.
Thanks in advance.

Bob.



The question I posted on frontpage.client:

Some background info: At my workplace they use intranet that's completely
built in Frontpage. It is hosted by two web servers: a Staging or in other
words development and test server and a Production server. This intranet
complies of about +- 20000 files varying from HTML pages, Forms, pictures,
doc and pdf files. The servers are Windows 2000 servers with IIS and
Frontpage Extensions 2002 installed. On the workstations we have Windows XP
SP1 Dutch language with Frontpage 2003.
There are quite some Authors that edit pages with Frontpage using the
Staging server. And there are but a few Admins that are authorized to publish
them to the Production server.
Previoussly there was a FTP process that took place at night to syncronize
the two web servers. But that caused problems with Forms and publishing from
Frontpage, and it corrupted the Frontpage Extension on the web server.
These problems are now solved, and the process is turned off. But now the
pages has to be publish by hand. You can imagine that this can take much more
time and effort. The admins that carys out these tasks, would like to see
that this takes place automatically.

My question is this: Is there a way to schedule the publishing task at fixed
times in the same technical way as when you publish by hand using Frontpage?
FTP tools or other kind of synchrosation tools causes problems with
Frontpage Extensions.

Thank you very much in advance.

Bob.
 
S

Stefan B Rusynko

The link you found to
http://msdn2.microsoft.com/en-us/library/aa140110(office.10).aspx
is probably what you need
If you have any experience w/ VBA you should be able to make the code from that link run
You'll find more info on the FP Web Object model at
http://msdn2.microsoft.com/en-us/library/aa209306(office.11).aspx

PS
You mention using Task Scheduler. TBMK, FP does not have a built in On Start Event handler, so setting it up in Windows Task
Scheduler to auto run at preset times will not be possible directly from FP
But you can set up a Task scheduler event from either a Windows Form (say using VB) or from an Office Program (like an Excel
workbook)
To see how to access the FP Object model from Excel see
http://msdn2.microsoft.com/en-us/library/aa221102(office.11).aspx
The OLE Programmatic Identifier you will need in Excel is
Dim myNewFP As Variant
Set myNewFP = CreateObject("FrontPage.Application")
Or
Dim objApp As FrontPage.Application
Set objApp = GetObject(, "FrontPage.Application")

(several years ago I create a similar Excel Workbook for a client to autorun from Task Scheduler and access several FP webs to run
some FP reports)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Dear Readers,
|
| I have a question about scheduling the publishing task in Frontpage. I
| already had a question in the newsgroup frontpage.client. David Berry pointed
| me out to use VBA, and he gave me an simple example in VBA. I am searching
| for other examples in VBScript with more error handling. I then can use
| VBScript to schedule the publishing task.
| Thanks in advance.
|
| Bob.
|
|
|
| The question I posted on frontpage.client:
|
| Some background info: At my workplace they use intranet that's completely
| built in Frontpage. It is hosted by two web servers: a Staging or in other
| words development and test server and a Production server. This intranet
| complies of about +- 20000 files varying from HTML pages, Forms, pictures,
| doc and pdf files. The servers are Windows 2000 servers with IIS and
| Frontpage Extensions 2002 installed. On the workstations we have Windows XP
| SP1 Dutch language with Frontpage 2003.
| There are quite some Authors that edit pages with Frontpage using the
| Staging server. And there are but a few Admins that are authorized to publish
| them to the Production server.
| Previoussly there was a FTP process that took place at night to syncronize
| the two web servers. But that caused problems with Forms and publishing from
| Frontpage, and it corrupted the Frontpage Extension on the web server.
| These problems are now solved, and the process is turned off. But now the
| pages has to be publish by hand. You can imagine that this can take much more
| time and effort. The admins that carys out these tasks, would like to see
| that this takes place automatically.
|
| My question is this: Is there a way to schedule the publishing task at fixed
| times in the same technical way as when you publish by hand using Frontpage?
| FTP tools or other kind of synchrosation tools causes problems with
| Frontpage Extensions.
|
| Thank you very much in advance.
|
| Bob.
|
 
M

Mossier

Hi Stefan,

Thanks for the Object Model, that was helpfull. Also the first article was
missing the PublishWeb function. I created my own to work from your earlier
example:

Public Function PublishWeb(pDestination, pFpPubFlags) As Boolean
Dim webIntranet As Web
Set webIntranet = Application.ActiveWeb 'Web Must be Open

webIntranet.Publish pRootURL, pFpPubParam
PublishWeb = True
End Function

This probably sounds silly, but how do I programmatically open a Web page,
without any user interaction?

Thanks again.

Bob.

Stefan B Rusynko said:
The link you found to
http://msdn2.microsoft.com/en-us/library/aa140110(office.10).aspx
is probably what you need
If you have any experience w/ VBA you should be able to make the code from that link run
You'll find more info on the FP Web Object model at
http://msdn2.microsoft.com/en-us/library/aa209306(office.11).aspx

PS
You mention using Task Scheduler. TBMK, FP does not have a built in On Start Event handler, so setting it up in Windows Task
Scheduler to auto run at preset times will not be possible directly from FP
But you can set up a Task scheduler event from either a Windows Form (say using VB) or from an Office Program (like an Excel
workbook)
To see how to access the FP Object model from Excel see
http://msdn2.microsoft.com/en-us/library/aa221102(office.11).aspx
The OLE Programmatic Identifier you will need in Excel is
Dim myNewFP As Variant
Set myNewFP = CreateObject("FrontPage.Application")
Or
Dim objApp As FrontPage.Application
Set objApp = GetObject(, "FrontPage.Application")

(several years ago I create a similar Excel Workbook for a client to autorun from Task Scheduler and access several FP webs to run
some FP reports)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Dear Readers,
|
| I have a question about scheduling the publishing task in Frontpage. I
| already had a question in the newsgroup frontpage.client. David Berry pointed
| me out to use VBA, and he gave me an simple example in VBA. I am searching
| for other examples in VBScript with more error handling. I then can use
| VBScript to schedule the publishing task.
| Thanks in advance.
|
| Bob.
|
|
|
| The question I posted on frontpage.client:
|
| Some background info: At my workplace they use intranet that's completely
| built in Frontpage. It is hosted by two web servers: a Staging or in other
| words development and test server and a Production server. This intranet
| complies of about +- 20000 files varying from HTML pages, Forms, pictures,
| doc and pdf files. The servers are Windows 2000 servers with IIS and
| Frontpage Extensions 2002 installed. On the workstations we have Windows XP
| SP1 Dutch language with Frontpage 2003.
| There are quite some Authors that edit pages with Frontpage using the
| Staging server. And there are but a few Admins that are authorized to publish
| them to the Production server.
| Previoussly there was a FTP process that took place at night to syncronize
| the two web servers. But that caused problems with Forms and publishing from
| Frontpage, and it corrupted the Frontpage Extension on the web server.
| These problems are now solved, and the process is turned off. But now the
| pages has to be publish by hand. You can imagine that this can take much more
| time and effort. The admins that carys out these tasks, would like to see
| that this takes place automatically.
|
| My question is this: Is there a way to schedule the publishing task at fixed
| times in the same technical way as when you publish by hand using Frontpage?
| FTP tools or other kind of synchrosation tools causes problems with
| Frontpage Extensions.
|
| Thank you very much in advance.
|
| Bob.
|
 
S

Stefan B Rusynko

In the same way
See http://msdn2.microsoft.com/en-us/library/aa208665(office.11).aspx

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Hi Stefan,
|
| Thanks for the Object Model, that was helpfull. Also the first article was
| missing the PublishWeb function. I created my own to work from your earlier
| example:
|
| Public Function PublishWeb(pDestination, pFpPubFlags) As Boolean
| Dim webIntranet As Web
| Set webIntranet = Application.ActiveWeb 'Web Must be Open
|
| webIntranet.Publish pRootURL, pFpPubParam
| PublishWeb = True
| End Function
|
| This probably sounds silly, but how do I programmatically open a Web page,
| without any user interaction?
|
| Thanks again.
|
| Bob.
|
| "Stefan B Rusynko" wrote:
|
| > The link you found to
| > http://msdn2.microsoft.com/en-us/library/aa140110(office.10).aspx
| > is probably what you need
| > If you have any experience w/ VBA you should be able to make the code from that link run
| > You'll find more info on the FP Web Object model at
| > http://msdn2.microsoft.com/en-us/library/aa209306(office.11).aspx
| >
| > PS
| > You mention using Task Scheduler. TBMK, FP does not have a built in On Start Event handler, so setting it up in Windows Task
| > Scheduler to auto run at preset times will not be possible directly from FP
| > But you can set up a Task scheduler event from either a Windows Form (say using VB) or from an Office Program (like an Excel
| > workbook)
| > To see how to access the FP Object model from Excel see
| > http://msdn2.microsoft.com/en-us/library/aa221102(office.11).aspx
| > The OLE Programmatic Identifier you will need in Excel is
| > Dim myNewFP As Variant
| > Set myNewFP = CreateObject("FrontPage.Application")
| > Or
| > Dim objApp As FrontPage.Application
| > Set objApp = GetObject(, "FrontPage.Application")
| >
| > (several years ago I create a similar Excel Workbook for a client to autorun from Task Scheduler and access several FP webs to
run
| > some FP reports)
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
| >
| > | Dear Readers,
| > |
| > | I have a question about scheduling the publishing task in Frontpage. I
| > | already had a question in the newsgroup frontpage.client. David Berry pointed
| > | me out to use VBA, and he gave me an simple example in VBA. I am searching
| > | for other examples in VBScript with more error handling. I then can use
| > | VBScript to schedule the publishing task.
| > | Thanks in advance.
| > |
| > | Bob.
| > |
| > |
| > |
| > | The question I posted on frontpage.client:
| > |
| > | Some background info: At my workplace they use intranet that's completely
| > | built in Frontpage. It is hosted by two web servers: a Staging or in other
| > | words development and test server and a Production server. This intranet
| > | complies of about +- 20000 files varying from HTML pages, Forms, pictures,
| > | doc and pdf files. The servers are Windows 2000 servers with IIS and
| > | Frontpage Extensions 2002 installed. On the workstations we have Windows XP
| > | SP1 Dutch language with Frontpage 2003.
| > | There are quite some Authors that edit pages with Frontpage using the
| > | Staging server. And there are but a few Admins that are authorized to publish
| > | them to the Production server.
| > | Previoussly there was a FTP process that took place at night to syncronize
| > | the two web servers. But that caused problems with Forms and publishing from
| > | Frontpage, and it corrupted the Frontpage Extension on the web server.
| > | These problems are now solved, and the process is turned off. But now the
| > | pages has to be publish by hand. You can imagine that this can take much more
| > | time and effort. The admins that carys out these tasks, would like to see
| > | that this takes place automatically.
| > |
| > | My question is this: Is there a way to schedule the publishing task at fixed
| > | times in the same technical way as when you publish by hand using Frontpage?
| > | FTP tools or other kind of synchrosation tools causes problems with
| > | Frontpage Extensions.
| > |
| > | Thank you very much in advance.
| > |
| > | Bob.
| > |
| >
| >
| >
 
M

Mossier

Hello,

I have build a solution for my problem in Visual Basic Script (.vbs). That
way I can schedule it nightly by the Task Scheduler. The Task Scheduler takes
care of the authentication.
Here is the code, it takes three inputs, the sourceweb url, the destination
url, and the cumulative flags.
e.g. Publish.vbs http://webserver1/intranet http://webserver2/intranet 19

---

Option Explicit

' LogFile Configuration
Const bEnableLogging = True
Dim bPrependDateStampInLogFileName
Dim sOverWriteORAppend, sLogFile
bPrependDateStampInLogFileName = True
sOverWriteORAppend = "overwrite"

Call Main()

Sub Main()

'Objects
Dim fpNewApp
Dim webIntranet
' Collect arguments
'pFpParamFlags:
'fpPublishNone = 0
'fpPublishIncremental = 1
'fpPublishAddToExistingWeb = 2
'fpPublishCopySubwebs = 4
'fpPublishLogInTempDir = 8
'fpPublishNoDeleteUnmatched = 16
'fpPublishUseLastPublishTime = 32
'fpPublishCopyAllFiles = 64

Dim pSourceWeb, pDestWeb, pFpParamFlags

LogToFile("Started")

On Error Resume Next
pSourceWeb = WScript.Arguments(0)
pDestWeb = WScript.Arguments(1)
pFpParamFlags = WScript.Arguments(2)

If pSourceWeb <> "" And pDestWeb <> "" And pFpParamFlags <> "" Then
LogToFile("Publishing " & pSourceWeb & " to " & pDestWeb & " with the
following flags " & pFpParamFlags)

Set fpNewApp = CreateObject("FrontPage.Application")
If Err.Number = 0 Then
LogToFile("FrontPage succesfully started.")

Set webIntranet = fpNewApp.Webs.Open (pSourceWeb)
If Err.Number = 0 Then
LogToFile("Web " & pSourceWeb & " succesfully opened.")

webIntranet.Publish pDestWeb, pFpParamFlags
If Err.Number = 0 Then
LogToFile("Web " & pDestWeb & " succesfully published.")

webIntranet.Close
LogToFile("Web " & pSourceWeb & " closed.")
End If
End If
Set webIntranet = Nothing
End If
Set fpNewApp = Nothing
Else
LogToFile("Not enough Arguments specified")
End If

If Err.Number <> 0 Then
LogToFile("Ended with errors: " & Err.Number & " " & Err.Description)
Else
LogToFile("End")
End If

End Sub


'To log error & general messages
Sub LogToFile(Message)

If bEnableLogging = False Then Exit Sub

Const ForWriting = 2
Const ForAppending = 8

Dim oLogFSO, oLogShell, oLogFile
Dim sLogFileDir, sNow

Set oLogFSO = CreateObject("Scripting.FileSystemObject")

Set oLogShell = CreateObject("WScript.Shell")
sLogFileDir = oLogShell.CurrentDirectory & "\"
Set oLogShell = Nothing

If bPrependDateStampInLogFileName Then
sNow = Replace(Replace(Now(),"/","-"),":",".")
sLogFile = sLogFileDir & sNow & " - " & "fp-log.txt"
bPrependDateStampInLogFileName = False
End If

If sOverWriteORAppend = "overwrite" Then
Set oLogFile = oLogFSO.OpenTextFile(sLogFile, ForWriting, True)
sOverWriteORAppend = "append"
Else
Set oLogFile = oLogFSO.OpenTextFile(sLogFile, ForAppending, True)
End If

Message = Now & " " & Message

oLogFile.WriteLine(Message)

oLogFile.Close
oLogFSO = Null
End Sub

----

Thanks for all the suggestions,

Bob.
 

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

Top