Help and Support

文書番号: 262987 - 最終更新日: 2007年6月29日 - リビジョン: 3.1

[FP2003] [HOWTO] オートメーションを使用して FrontPage で新しい Web の作成とナビゲーション構成の設定を行う方法

すべて展開する | すべて折りたたむ

概要

この資料では、Microsoft FrontPage のオートメーションを使用して、新しい FrontPage Web の作成、空白 HTML ページの追加、ナビゲーション構成の追加、および既存ページへの HTML の挿入を行う方法を説明しています。

詳細

サンプルを作成するには、次の手順を実行します。
  1. Visual Basic を起動し、[標準 EXE] プロジェクトを新規作成します。デフォルトで Form1 が作成されます。
  2. [プロジェクト] メニューの [参照設定] をクリックして、[参照設定] ダイアログ ボックスを表示します。Office FrontPage 2003 の場合は、[Microsoft FrontPage 6.0 Web Object Reference Library] および [Microsoft FrontPage 6.0 Page Object Reference Library] をオンにします。FrontPage 2002 の場合は、[Microsoft FrontPage 5.0 Web Object Reference Library] および [Microsoft FrontPage 5.0 Page Object Reference Library] をオンにします。FrontPage 2000 の場合は、[Microsoft FrontPage 4.0 Web Object Reference Library] および [Microsoft FrontPage 4.0 Page Object Reference Library] をオンにします。[OK] をクリックして、ダイアログ ボックスを閉じます。
  3. [CommandButton] コントロールを [Form1] に追加します。
  4. Form1 のコード ウィンドウに、次のコードを挿入します。
    Option Explicit
     
    ' Define constants
    Const Servername = "http://ServerName"
    Const FPWebFolder = "FPTest"
    Private Sub Command1_Click()
     Dim oFPweb As Frontpage.Web
     Dim oFP As Frontpage.Application
     
     ' Create an instance of FrontPage
     Set oFP = CreateObject("Frontpage.Application")
     ' Create a new web
     Set oFPweb = oFP.Webs.Add(Servername & "/" & FPWebFolder)
     ' Show FrontPage
     oFPweb.Activate
     ' Add 3 new files
     With oFPweb.RootFolder.Files
       .Add "default.htm"
       .Add "temp1.htm"
       .Add "temp2.htm"
    End With
      
     ' Apply the navigation structure to the web
     ApplyNavigationStructure oFP
     ' Add comments to each of the files
     AddCommentToFile oFP, "default.htm"
     AddCommentToFile oFP, "temp1.htm"
     AddCommentToFile oFP, "temp2.htm"
     ' Set variables to nothing and shut down FrontPage
     ' by calling oFP.WebWindows.Close
     Set oFPweb = Nothing
     oFP.WebWindows.Close
     Set oFP = Nothing
    End Sub
    Private Sub ApplyNavigationStructure(oFP As Frontpage.Application)
      Dim oPagewin As Frontpage.PageWindow
      Dim oFPdoc As FrontpageEditor.IHTMLDocument2
      Dim oBot As FrontpageEditor.FPHTMLFrontpageBotElement
      Dim oNavNode As Frontpage.NavigationNode
      
      ' Get the home page navigation node
      Set oNavNode = oFP.ActiveWeb.HomeNavigationNode
      ' Add two children to the home page
      oNavNode.children.Add "temp1.htm", "Child #1 (temp1.htm)", fpStructLeftmostChild
      oNavNode.children.Add "temp2.htm", "Child #2 (temp2.htm)", fpStructRightmostChild
      ' Apply the structure
      oFP.ActiveWeb.ApplyNavigationStructure
      ' Set the shared borders for the current web
      oFP.ActiveWeb.SharedBorders = fpBorderLeft Or fpBorderBottom
     
      ' Load the _borders/left.htm file
      Set oPagewin = oFP.LocatePage(Servername & "/" & FPWebFolder & _
                     "/_borders/left.htm", fpPageViewDefault)
      oPagewin.Activate
      ' Get the Document object
      Set oFPdoc = oPagewin.Document
      ' Look for the "Navigation" webbot
      For Each oBot In oFPdoc.All.tags("webbot")
        If oBot.getBotAttribute("bot") = "Navigation" Then  
          ' Add a link to the home page to the navigation bot
          Call oBot.setBotAttribute("b-include-home", "TRUE")
    End If
      Next oBot
      ' Save left.htm
      oPagewin.Save
      ' Close the file
      oPagewin.Close
    End Sub
    Private Sub AddCommentToFile(oFP As Frontpage.Application, filename As String)
      Dim oPagewin As Frontpage.PageWindow
      Dim oFPdoc As FrontpageEditor.IHTMLDocument2
      
      ' Load the file to be edited
      Set oPagewin = oFP.LocatePage(Servername & "/" & FPWebFolder & "/" & filename, fpPageViewDefault)
      oPagewin.Activate
      ' Get the document object
      Set oFPdoc = oPagewin.Document
      ' Replace the HTML with the commented HTML
      oFPdoc.body.outerHTML = "<body><p>This file is <b>" & filename & "</b></p></body>"
      ' Save the page
      oPagewin.Save True
      ' Close the page
      oPagewin.Close
    End Sub
    					
    : 上記のコードで、定数 "ServerName" の部分は使用している Web サーバーの名前に変更します。

  5. F5 キーを押してプロジェクトを実行します。

関連情報

Office オートメーションの詳細については、以下の Microsoft Office Development サポート サイトを参照してください。

http://msdn2.microsoft.com/en-us/library/aa188489(office.10).aspx (http://msdn2.microsoft.com/en-us/library/aa188489(office.10).aspx)

関連情報

この資料は米国 Microsoft Corporation から提供されている Knowledge Base の Article ID 262987? (http://support.microsoft.com/kb/262987/EN-US/ ) (最終更新日 2003-09-25) を基に作成したものです。

この資料に含まれているサンプル コード/プログラムは英語版を前提に書かれたものをありのままに記述しており、日本語環境での動作は確認されておりません。

この資料は以下の製品について記述したものです。
  • Microsoft Office FrontPage 2003
  • Microsoft FrontPage 2002 Standard Edition
  • Microsoft FrontPage 2000 Standard Edition
  • Microsoft Visual Basic 6.0 Professional Edition
キーワード:?
kbhowto kbautomation KB262987
"Microsoft Knowledge Baseに含まれている情報は、いかなる保証もない現状ベースで提供されるものです。Microsoft Corporation及びその関連会社は、市場性および特定の目的への適合性を含めて、明示的にも黙示的にも、一切の保証をいたしません。さらに、Microsoft Corporation及びその関連会社は、本文書に含まれている情報の使用及び使用結果につき、正確性、真実性等、いかなる表明・保証も行ないません。Microsoft Corporation、その関連会社及びこれらの権限ある代理人による口頭または書面による一切の情報提供またはアドバイスは、保証を意味するものではなく、かつ上記免責条項の範囲を狭めるものではありません。Microsoft Corporation、その関連会社 及びこれらの者の供給者は、直接的、間接的、偶発的、結果的損害、逸失利益、懲罰的損害、または特別損害を含む全ての損害に対して、状況のいかんを問わず一切責任を負いません。(Microsoft Corporation、その関連会社 またはこれらの者の供給者がかかる損害の発生可能性を了知している場合を含みます。) 結果的損害または偶発的損害に対する責任の免除または制限を認めていない地域においては、上記制限が適用されない場合があります。なお、本文書においては、文書の体裁上の都合により製品名の表記において商標登録表示、その他の商標表示を省略している場合がありますので、予めご了解ください。"

サポート技術情報の翻訳