这是一个用vb访问frontpage并进行操作的程序,在程序中总是出现--实时错误'91' 对象变量或With块变量未设置--这样的错误.这段代码在运行前要添加引用Microsoft Office FrontPage Object Reference Library. 求高手指点一下.
Private Sub Command1_Click()
Dim fpApp As FrontPage.Application
Dim Webwindow As WebWindowEx
Dim Pagewindow As PageWindowEx
Dim PageWindows As PageWindows
Dim objDoc As DispFPHTMLDocument
Dim ele As IHTMLElement
Dim strFile As String
Dim i As Integer
strFile = "e:\index.htm"
Set fpApp = FrontPage.Application
Set Webwindow = fpApp.ActiveWebWindow
Set PageWindows = fpApp.ActiveWebWindow.PageWindows
Set Pagewindow = PageWindows.Item(0)
Set objDoc = FrontPage.ActiveDocument
fpApp.Application.ActiveWebWindow.PageWindows.Add (strFile)
Webwindow.Visible = True
With fpApp.ActiveDocument
List1.AddItem "bgcolor=" & .bgColor
List1.AddItem "Title=" & .Title
List1.AddItem "anchors.length=" & .anchors.length '输出书签数量
List1.AddItem "anchors(0)=" & .anchors.Item(0).Name '第一个书签名"
List1.AddItem "anchors(1)=" & .anchors.Item(1).Name '第二个书签名"
List1.AddItem "images.length =" & .images.length
List1.AddItem "images .width =" & .images.Item(1).Width
List1.AddItem "images .height =" & .images.Item(1).Height
List1.AddItem "" & .images.Item(1).src
End With
fpApp.Application.ActiveWebWindow.Close
'fpApp.Quit
Set fpApp = Nothing
End Sub