Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Frontpage Macro Programming

News See Also Recommended Books Recommended Links Document Object Model Tutorials Recommended Papers VBA
Microsoft Articles and How-to documents Macros
 by Stephen Travis
Finding and replacing text  FrontPage SDK Tips  Random Findings Humor Etc

FrontPage is programmable in VBA and you can write useful macros for it. But it's not easy. Unfortunately Microsoft did everything it could to block FrontPage users from utilizing its VBA programmability ;-)

One notable deficiency of  FrontPage 2000-2003 (versions before 2000 did not have VBA programmability, and I think version after 2003  -- ExpressionWeb -- does not have it either) is that there is no macro recording capability. Theoretically macros can be used to do frequently performed tasks in FrontPage.  But details are not trivial and very difficult to implement without good knowledge of both VBA, Javascript and DOM.

For example there is an important and very useful capability to implement specific  search  and replace operations using macros.  Tremendous opportunities are connected with reusing saved "search and replace" operations, which are simple XML file.  Sounds great but the only example of xml representation of the query that controls behavior of the search module is the converted string:

 strQuery = "<?xml version=""1.0""?>" & _
"<fpquery version=""1.0"">" & _
"<find tag=""b"">" & _
"<rule type=""insideTag"" tag=""td"" />" & _
"</find>" & _
"<replace type=""changeTag"" tag=""i"" />" & _
"</fpquery>"

The main limitation here is that search string in hard-coded into VBA literal. Of course you can write a "string generator" in Perl to create such strings from any saved query, but a better way is to read it from the file directly in VBA. I think that it's not possible or at least not easy. Microsoft does not provide any additional information other then this example. If we try to search Frontpage 2003 help we will get the same example with some additional VBA code:

The following example searches for TD elements in the current selection and adds the align attribute with a value of "center."

Dim objSearch As SearchInfo
Dim objRange As IHTMLTxtRange
Dim blnMatches As Boolean
Dim strQuery As String

strQuery = "<?xml version=""1.0""?><fpquery version=""1.0"">" & _
    "<find tag=""td""><rule type=""insideTag"" tag=""table"" />" & _
    "</find><replace type=""setAttribute"" attribute=""align"" " & _
    "value=""center""/></fpquery>"

Set objRange = ActiveDocument.selection.createRange
Set objSearch = Application.CreateSearchInfo

objSearch.QueryContents = strQuery
blnMatches = Application.ActiveDocument.Find(objSearch, Nothing, objRange)
If blnMatches = True Then objRange.Select

Only after a lot of digging you understand that search query can be saved from the FrontPage menu and content of the saved query can be pasted into the macro.  So you do not need to think much about XML representation of the query -- Frontpage can do this job for you. Actually just this capability can be used for writing very useful macros.

Frontpage's Visual Basic Editor  can be envoked by Alt-F11 or  Tools/Macro/Visual Basic Editor).  Open the FrontPage Visual Basic Editor.

Once inside the VBE, you can begin to write your code. As with other Office applications  you can add additional code modules, forms, and even classes to your macro project. However, if you plan to share any of the macros, you will likely want to create an add-in. For more information on add-ins, see About Add-ins.

Macros are stored in the file called Microsoft FrontPage.fpm in the FrontPage macros folder. 

On computer running Microsoft Windows 2000 and 2003, this is usually

C:\Documents and Settings\[user name]\Application Data\Microsoft\FrontPage\Macros.

It it closed when Frontpage is closed so you can export it to other computers.

Here is a useful macro that works and that demonstrates how to insert text:

'   navigationTree -  Indented List from FrontPage Navigation
'   Copyright (C) 2002  Stephen C. Travis
'
'   This program is free software; you can redistribute it and/or modify
'   it under the terms of the GNU General Public License as published by
'   the Free Software Foundation; either version 2 of the License, or
'   (at your option) any later version.
'
'   This program is distributed in the hope that it will be useful,
'   but WITHOUT ANY WARRANTY; without even the implied warranty of
'   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'   GNU General Public License for more details.
'
'   You should have received a copy of the GNU General Public License
'   along with this program; if not, write to the Free Software
'   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
'   or visit their website at http://www.fsf.org/licenses/gpl.txt
'
Dim myHTML As String
Sub navigationTree()
If Not FrontPage.ActiveDocument Is Nothing Then
If FrontPage.ActivePageWindow.ViewMode = fpPageViewNormal Then
    Dim thisNode As NavigationNode
    Set thisNode = ActiveWeb.HomeNavigationNode
    myHTML = "<ul>"
    Call getChildren(thisNode)
    myHTML = myHTML & "</ul>"
    Set myRange = ActiveDocument.selection.createRange
    myRange.collapse (True)
    myRange.pasteHTML (myHTML)
End If
End If
End Sub
Private Sub getChildren(thisNode)
    myHTML = myHTML & "<li>"
    myHTML = myHTML & "<a href=""" & MakeRel(ActiveDocument, thisNode.Url) & """>" & thisNode.File.Title & "</a>"
    For i = 0 To thisNode.Children.count - 1
        myHTML = myHTML & "<ul>"
        getChildren (thisNode.Children(i))
        myHTML = myHTML & "</ul>"
    Next
    myHTML = myHTML & "</li>"
End Sub

Below in another useful (and working) sample:  Save All command -- a command that saves all the open pages:

Sub Save_All() 'Name of the macro
  'Checks that the document is in Page view in FrontPage
  'And that at least one page is open
  If (Application.ActiveWebWindow.ViewMode = fpWebViewPage _
      And ActiveWebWindow.PageWindows.Count > 0) Then
      Dim activePage, page As PageWindow 'Declare variables 
      'Set the variable ActivePage to the
      'current active page 
      Set activePage = ActivePageWindow
      'Loop through all open pages
      For Each page In ActiveWebWindow.PageWindows
          page.Activate
          'Click the Save button for each page
          CommandBars("Add Command").Controls("&File"). _
            Controls("&Save").Execute 
      Next
      'Display the page you were working on when
      'the Save All command was clicked
      activePage.Activate
  End If
End Sub
  1. In FrontPage, click Customize on the Tools menu.
  2. Click the Commands tab, and then select Macros in the Categories list.
  3. Drag and drop the entry Custom Menu Item from the Commands list to the File menu beneath the Save command.
  4. Click Modify Selection, change the name to Save A&ll, and then press ENTER. Note  The ampersand in the word All makes the first "L" a keyboard shortcut. After the command is added to the File menu, you can press ALT+L to save all open pages.
  5. Click Modify Selection again, and then choose Assign Macro.
  6. Choose Save_All from the list, and then click OK.
  7. Click Close.

The Save All command is added to the File menu.

Add-ins

Add-ins are supplemental programs that extend the capabilities of Microsoft FrontPage by adding custom commands and specialized features. You can obtain add-ins from the Microsoft Office Online Web site, third-party vendors, or you can write your own custom add-in programs by using Microsoft Visual Basic for Applications.

Sub OpenAndEditPages()
    Dim objPage As FPHTMLDocument
    Dim objFile As WebFile
    Dim objPageWindow As PageWindowEx
    Dim objHead As IHTMLElement
    Dim strMetaTag As String

    strMetaTag = "" & vbCrLf & _
        vbTab & "" & vbCrLf

    For Each objFile In ActiveWeb.RootFolder.Files
        If objFile.Extension = "htm" Or objFile.Extension = "html" Then
            objFile.Open
            Set objPageWindow = ActivePageWindow
            Set objPage = objPageWindow.Document

            'Add meta tag to each of the pages.
            Set objHead = objPage.all.tags("head").Item(0)
            Call objHead.insertAdjacentHTML("BeforeEnd", strMetaTag)

            'Now save and close the page window.
            objPageWindow.SaveAs objPageWindow.Document.Url
            objPageWindow.Close False
        End If
    Next objFile
End Sub
Sub SelectFilesFromFileOpenDialog()
    Dim objFileOpen As FileDialog
    Dim strFolder As String
    Dim strFile As Variant
    Dim intCount As Integer

    'Creates the File Open dialog object.
    Set objFileOpen = FrontPage.Application.FileDialog(msoFileDialogOpen)

    'Specifies the root folder of the active Web site as the startup folder.
    strFolder = ActiveWeb.RootFolder
    strFolder = Replace(strFolder, "file:///", "")
    strFolder = Replace(strFolder, "/", "\")
    objFileOpen.InitialFileName = strFolder

    'Opens the selected files in FrontPage.
    If objFileOpen.Show < 0 Then
        For Each strFile In objFileOpen.SelectedItems
            ActiveWebWindow.PageWindows.Add strFile
        Next
    End If
End Sub

To conserve memory and increase the speed of FrontPage, it's a good idea to unload add-in programs you don't use often. When you unload an add-in, its features and commands are removed from FrontPage, but the add-in file itself remains on your computer for easy reloading.

Developers can use Component Object Model (COM)  add-ins, which provide additional functionality in a variety of programming languages, including Microsoft Visual Basic, Microsoft Visual C++, and Microsoft Visual J++. As a developer, you'll find information about designing COM add-ins in Visual Basic Help. While you are developing and testing, you can load or unload a COM add-in in FrontPage before you have a working installation program for your add-in.

Note  Do not confuse add-ins with plug-ins. A plug-in is one of a set of software modules that integrate into Web browsers to offer a range of interactive and multimedia capabilities.

Security  Security vulnerabilities in external files or controls may extend to Web pages that use those items. For example, external style sheets (files with a .css extension), script files (files with a .js extension), custom ASP.NET controls, or other items, may pose a security risk. Be sure your style sheets, add-ins, themes, executables, scripts, controls, or other files come from trusted sources.


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Mar 01, 2011] Microsoft Bob Useful FrontPage Links

The FrontPage SDKs are no longer available from Microsoft, so I have them mirrored here:
File Description File Link File Size
FrontPage 1.0 SDK fpsdk10.zip 3.25 mb
FrontPage 1.1 SDK fpsdk11.zip 706.24 kb
FrontPage 97 SDK fpsdk20.zip 1.04 mb
FrontPage 98 SDK fpsdk30.zip 1.46 mb
FrontPage 2000 SDK fpsdk40.zip 797.12 kb
FrontPage 2002 SDK fpsdk50.zip 1.52 mb

[Feb 02, 2011] Microsoft Bob Archive

2011-02-02 Manually Localizing FPSE 2002 for Windows Server 2008 and Windows Vista 0 None
2011-01-31 Life after FPSE (Part 6) 0 None
2009-04-05 FrontPage Macro: Fix Filenames 0 None
2008-02-17 FrontPage Macro: Disable Right-Click and Text Selection 0 None
2008-02-17 FrontPage Macro: Build Folder URL Tree 0 None
2008-02-17 FrontPage Macro: Reformat HTML 0 None
2007-01-03 Useful FrontPage Links 0 None
2006-12-14 Determining Access Column Types for FrontPage Database Results Fields 0 None
2006-05-30 Miscellaneous FrontPage Marketing Images 0 None
2006-05-30 FrontPage Versions and Timeline 0 None
2005-06-25 FrontPage and Text File Databases 0 None
2004-11-23 How to enable or change multiple FrontPage/ASP.NET database editor users 0 None
2003-03-06 FrontPage Visio Viewer Web Component 0 None
2001-05-03 History of the FrontPage Personal Web Server 0 None
2000-10-23 The Early FrontPage History

http://msdn.microsoft.com/office/default.aspx?pull=/library/en-us/odc_fp2003_ta/html/odc_fpWorkingWithHTMLProgrammatically.asp

1.1.1 Accessing the Position of the Insertion Point

Accessing specific elements is relatively simple. However, usually you want to access the element that is at the position of the insertion point. You may want to access the text and HTML elements that are selected or perhaps just insert text or HTML into the page without replacing any existing text. There are two ways to do this. One way uses the activeElement property, and the other uses an IHTMLSelectionObject object.

1.1.1.1 Accessing the active element

Sometimes you might want to access the currently selected element or the element that is at the position of the insertion point. To do this, you use the activeElement property of the FPHTMLDocument or IHTMLDocument object. The activeElement property returns an IHTMLElement object. The following example uses the activeElement property to create an object variable that accesses the element at the insertion point.

Dim objElement As IHTMLElement
Set objElement = ActiveDocument.activeElement

The previous example uses an IHTMLElement object to store a pointer to the active element. However, sometimes you might want to use the exact type of object. In this case you need to know the type of the active element. To do this, you can use the tagName property to return a String that contains the name of the tag. Then you need to determine which FPHTML object corresponds to that element. The following example shows a Select statement that sets the object variable based on the value of the tagName property.

Dim strTagName As String
strTagName = ActiveDocument.activeElement.TagName
Select Case LCase(strTagName)
    Case "body"
        Dim objBody As FPHTMLBody
        Set objBody = ActiveDocument.activeElement
    Case "p"
        Dim objP As FPHTMLParaElement
        Set objP = ActiveDocument.activeElement
    Case "div"
        Dim objDiv As FPHTMLDivElement
        Set objDiv = ActiveDocument.activeElement
    Case "span"
        Dim objSpan As FPHTMLSpanElement
        Set objSpan = ActiveDocument.activeElement
    Case Else
        Dim objElement As IHTMLElement
        Set objElement = ActiveDocument.activeElement
End Select

1.1.1.2 Accessing selected text and HTML

To access the selected text or the position of the insertion point, use the createRange method of the IHTMLSelectionObject object to create an IHTMLTxtRange object. To access the IHTMLSelectionObject object for a document, use the selection property of the FPHTMLDocument object.

The following example creates an IHTMLTxtRange object with the currently selected text. If no text is selected, the example accesses the position of the insertion point.

Dim objSelection As IHTMLTxtRange
Set objSelection = ActiveDocument.Selection.createRange

You can also create an IHTMLTxtRange object by using the createTextRange method of the IHTMLBodyElement or FPHTMLBody object. This approach places the entire body of the page into the text range.

Note You can access the createTextRange method from the FPHTMLButtonElement, IHTMLButtonElement, FPHTMLInputButtonElement, IHTMLInputButtonElement, FPHTMLInputHiddenElement, IHTMLInputHiddenElement, FPHTMLInputTextElement, IHTMLInputTextElement, FPHTMLTextAreaElement, and IHTMLTextAreaElement objects; however, doing so doesn't have an effective use in this case, so this article doesn't discuss the createTextRange method in relation to these objects.

1.1.1.3 Inserting text at the insertion point

After you create a text range with the selection, you can insert text or HTML at the location of the insertion point and replace the current selection with text or HTML.

You use the text property to insert text at the insertion point, as shown in the following example.

Dim objSelection As IHTMLTxtRange
Set objSelection = ActiveDocument.Selection.createRange
objSelection.Text = "The quick red fox jumped over the lazy brown dog."

1.1.1.4 Inserting HTML at the insertion point

If you use the text property to insert HTML, FrontPage converts the tags and special symbols to their HTML equivalents. Therefore, to insert HTML into a page, use the pasteHTML method of the IHTMLTxtRange object, as shown in the following example.

Dim objSelection As IHTMLTxtRange
Set objSelection = ActiveDocument.Selection.createRange
objSelection.pasteHTML "<b>The quick red fox jumped over the lazy brown dog.</b>

The IHTMLTxtRange object includes an htmlText property that you can use to read the selected HTML and text. However, the htmlText property is read-only; therefore, you can't use it to replace the selected HTML. In this case, use the htmlText property to read the selected text and HTML and the pasteHTML method to replace the selected text and HTML with HTML code. The following example shows how you might do this.

Dim objSelection As IHTMLTxtRange
Set objSelection = ActiveDocument.Selection.createRange
objSelection.pasteHTML "<div>" & objSelection.htmlText & "</div>"

Note The preceding code adds a <div> tag around the currently selected text. You should know and understand the HTML specification and HTML block elements to ensure the VBA code actually generates valid HTML. For example, adding only a table cell without the corresponding table row and table tags in the middle of a paragraph generates invalid HTML.

1.1.1.5 Collapsing a text range

Sometimes a user might have selected text, but the code that runs assumes that the user has no text selected. If the code that you need to write requires that the user has no text selected (for example, if you are inserting text or code that replaces selected text or code), you can use the collapse method to collapse the range. The collapse method has an optional Boolean parameter named start that indicates whether the range collapses to the start of the range or the end of the range. The default value is True, which indicates that the range collapses at the beginning of the range; a value of False indicates that the range collapses at the end of the range. The following example uses the collapse method to collapse the range at the end of the selected range and then inserts HTML code.

Dim objSelection As IHTMLTxtRange
Set objSelection = ActiveDocument.Selection.createRange
objSelection.collapse False
objSelection.pasteHTML "<div>The quick red fox jumped over the lazy brown dog.</div>"

1.1.2 Inserting Text and HTML into a Page

In addition to using the IHTMLTxtRange object to insert text and HTML code, you can also use the insertAdjacentText and insertAdjacentHTML methods. The insertAdjacentText and insertAdjacentHTML methods are members of the IHTMLElement object and therefore of most IHTML and FPHTML objects. When you have a handle to the appropriate object, you can use the insertAdjacentText or insertAdjacentHTML method to insert text or HTML into the document.

Both the insertAdjacentText and insertAdjacentHTML methods have a where parameter that takes a string and indicates whether the text or HTML is inserted before or after the opening or closing tag for the element. The possible values are "beforeBegin", "afterBegin", "beforeEnd", and "afterEnd". The following example inserts HTML before the closing tag if the active element is the BODY element and pastes it after the closing tag for all other elements.

Dim objElement As IHTMLElement
Dim strTagName As String
Set objElement = ActiveDocument.activeElement
strTagName = objElement.TagName
Select Case strTagName
    Case "body"
        objElement.insertAdjacentHTML where:="beforeEnd", _
            HTML:="<div>The quick red fox jumped over the lazy brown dog.</div>"
    Case Else
        objElement.insertAdjacentHTML where:="afterEnd", _
            HTML:="<div>The quick red fox jumped over the lazy brown dog.</div>"
End Select

1.1.3 Programmatically Selecting Text and Code

At times you may want to programmatically select text and code. You can do this using the select method of the IHTMLTxtRange object. Regardless of whether any text or code is selected, you can specify the element to select by using the moveToElementText method of the IHTMLTxtRange object, or you can select a specified range of text and code by using the move, moveEnd, or moveStart methods of the IHTMLTxtRange object.

The following example uses the moveToElementText and select methods to select the active element and the text it contains. If the selection spans several elements, the active element is the element that contains all other selected elements.

Dim objRange As IHTMLTxtRange
Dim objElement As IHTMLElement

Set objRange = ActiveDocument.Selection.createRange
Set objElement = ActiveDocument.activeElement

objRange.moveToElementText objElement
objRange.Select

1.1.4 Inserting META Data, Styles, and Scripts

As mentioned previously, the HEAD element of a Web page doesn't have an accessor property that you can use to access it and all child elements. There is also no corresponding FPHTML or IHTML object that you can use to access elements that are typically in the HEAD section of a Web page. To access some child elements for the HEAD element, such as the TITLE element, you can use the corresponding property of the FPHTMLDocument object, such as the title property.

Sometimes you might need to insert content into the HEAD section of a Web page, such as scripts, META data, and styles; for this reason you may need to access the HEAD element. To do this, you can use the method shown previously and create an IHTMLElement object variable, as shown in the following example.

Dim objHead As IHTMLElement 
Set objHead = ActiveDocument.all.tags("head").Item(0)

When you have access to the HEAD element, you can use the all method (as described previously) to access the child META, STYLE, and SCRIPT elements or use the InsertAdjacentHTML method to insert new elements into the HEAD section of a Web page. For example, you might need to add META data or insert a SCRIPT element. For more information and code examples, see Accessing Scripts and Adding Styles to Specified Elements.

[Dec 7, 2004] Automating Repetitive Tasks in FrontPage 2003

Do you ever find yourself performing the same steps over and over again? Perhaps you publish the same Web site to several locations and find yourself repeatedly typing the Web addresses into the Publish dialog box every time you need to publish the site. Or perhaps you want to add a reference to an external style sheet to every page in your Web site and don't want to open every page to paste the necessary HTML. Macros can help.

Macros allow you to automate repetitive tasks. If you've worked with other Microsoft® Office applications, you've probably worked with macros. In fact, several Office applications have a macro recorder that you can use to create macros for those applications. Although you can't record macros in FrontPage, you can still create macros to automate your tasks, and you can create some powerful macros. With a little instruction, you can begin to develop your own collection of macros.

[Nov 30, 2000] EDITING ASP FILES WITH MICROSOFT FRONTPAGE 2000

Did you know that you could safely edit Active Server Pages (ASP) files in the Microsoft FrontPage 2000 Web site creation and management tool? New and improved handling of ASP in FrontPage 2000, combined with a few basic rules for implementing ASP, allows developers to feel comfortable letting users edit pages that include ASP code. This article describes how FrontPage determines whether to display pages containing ASP code in Normal (WYSIWYG--what you see is what you get) View or HTML View, and describes how to create ASP code that allows users to safely edit the Web pages containing the ASP code in Normal View.

Product Home Page for Microsoft FrontPage
Product Overview of Microsoft FrontPage 2000
Free Downloads & Resources for Microsoft FrontPage Users
Online Support for Microsoft FrontPage
Publishing A Web Site with Microsoft FrontPage
Newsgroups for Microsoft FrontPage
Training & Certification for Microsoft FrontPage
Books for Microsoft FrontPage
Shop for Microsoft FrontPage 2000

Useful Shortcut Keys in FrontPage 2000

CONTROL WEB PAGE DEFAULT SETTINGS
As users of Microsoft Word are probably aware, every time you create a new document, Word bases that document on a template called Normal.dot. This template includes such information as the default font Word uses and the standard margins for pages. What you may not be aware of, however, is that Microsoft FrontPage uses a similar template whenever you create a new HTML document. By modifying this template, you can control many of the default settings on your HTML pages. In this article, you can see where FrontPage stores its template and how you can edit it:

Position and Layer Graphics and Text-Down to the Pixel-with FrontPage 2000

Using new positioning and layering tools in Microsoft FrontPage 2000, you can now place elements on your Web pages exactly where you want them. These new tools enable you to layer Web objects on top of one another, group them together as a unit, position graphics and text by setting precise pixel coordinates, wrap text around an image or text block, and more.

USEFUL SHORTCUT KEYS IN FRONTPAGE 2000

Do you find that using the keyboard is sometimes quicker than using your mouse? Shortcut keys can help you bypass menus and carry out commands directly. You can use shortcut keys in many ways with FrontPage, from accessing commands and toolbar buttons to outlining and editing information. Shortcut keys are sometimes listed next to the command name on menus. For more details, please go to:
http://officeupdate.microsoft.com/2000/focus/articles/FrontPageKeys.htm

THE JAVASCRIPT SOURCE TIP: IMAGE SLIDE SHOW

When you cut and paste this script in HTML view it will enable you to rotate a series of images in a page as a slideshow. You can customize the images and the time between each image. This script works best if all the images are the same dimension! Learn more at:
http://javascript.internet.com/miscellaneous/image-slideshow.html

How to create a macro for find&replace

June 26, 2009 8:59 PM

Fer Morfer

I have a macro in Word to translate chess notation. When I try to use it in Expression Web 2, the program crashes. It uses sentences like

WordBasic.EditReplace Find:=Str1$, Replace:=Str2$, Direction:=0, MatchCase:=1, WholeWord:=0, PatternMatch:=1, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=1

I suppose that the EditReplace command should be available here but I don't know how to name it (instead of WordBasic.)

I'm not a programmer. I'm a translator and I don't have special programming knowledge.

I also would like to obtain a reference of all available functions and expressions for building macros in this program. The help file of the Spanish edition of the macro editor (visual basic) has no information at all about them.

Steve Easton

Open EW.
Click Tools > Macro > Visual Basic editor
When the editor opens click View > Object browser.
The available classes will be displayed and clicking on one
will show the Sub classes, events and functions.

That is about as good as it gets because there is no SDK for EW.

That said, EW has an excellent built in Global find and replace feature
that can be used to replace anything in a page, in either the visible
web page or in the page code ( html )

Cheryl D Wise, FrontPage MVP

You can also save your find/replace searches and even link them to a button on your toolbar. Creating a series of find/replace searches and putting them on a custom toolbar (they call clean-up toolbar) is part of what Pat & Tina teach in their Migrating from FrontPage to Expression Web ebook and class.
  • MS MVP Expression Tutorials & Help http://by-expression.com and online instructor led Expression Classes
  • Fer Morfer

    Thank you very much! I didn't find the FinReplace option but I'll investigate it further.

    Regarding the advanced find and replace function, I have checked it, but it has a problem for me (or maybe I don't know how to use it properly. I can find the strings I need very well, but regarding replacing it is not so simple. For instance, I want to find all the expressions like Q[a-h] and then I want to replace in them the Q with a D. I find the strings without problems but then the program replace all "Q[a-h]" with a D and not merely the Q

    Fer Morfer

    Thanks a lot, Cheryl!

    As I told above, regarding the advanced find and replace function, I have checked it, but it has a problem for me (or maybe I don't know how to use it properly. I can find the strings I need very well, but regarding replacing it is not so simple. For instance, I want to find all the expressions like Q[a-h] and then I want to replace in them the Q with a D. I find the strings without problems but then the program replace all "Q[a-h]" with a D and not merely the Q.

    What I need is to detect and select the chess notation (and not the capital letters of normal words) and in them, I have to replace only one letter, not the whole chess exporession.

    Steve Easton

    You need to find: Q[a-h]
    and replace it with D[a-h]

    in other words find and replace the entire string


    FrontPage MV

    Fer Morfer

    Yes, but find Q[a-h] means finding any coincidence of Qa, Qb, Qc, Qd, Qe,Qf, Qg or Qh. When the program find a coincidence, then it select the whole coincidence, not only the Q And then if I write replace with D[a-h], the program takes it literally and replaces for instance "Qa" with "D[a-h]" That'si why I think I need a macro.

    Steve Easton

    Then you need to run a separate find replace for:
    Qa replaced with Da
    Qb replaced with Db

    and so on.

    Veign
    You need to find: Q[a-h]
    and replace it with D[a-h]
    in other words find and replace the entire string
    FrontPage MVP

    Regular Expressions only work with finding something. You can't replace text with a regular expression since a regular expression often has multiple valid states. Chris Hanscom - Microsoft MVP

    Steve Easton
    From the originla post I thought the OP was actually trying to replace Q[a-h] with D[a-h]

    and did not catch the part about Qa, Qb, Qc

    Fer Morfer
    Thanks a lot for your comments

    Well, that was an example. In chess there are 8 different pieces, with 8 files, and 8 ranks, so I think this would mean many searches and that the best solution would be to arrange a macro like the one I have for Word, if I learn how to do it properly.

    paladyn

    "In chess there are 8 different pieces... "

    Six. Rook, bishop, knight, king, queen, pawn. In algebraic notation there is no differentiation between black and white or kingside and queenside.

    cheers,
    scott

    Fer Morfer

    Yes, you are right. It was a typing mistake.
    In fact, I need only to identify in the text possible moves of 5 of them (Q, R, B, N, and K) because pawn moves are not identified by a capital letter, so they don't need translation.

    Fer Morfer

    The macro for Word is:

    Public Sub Main()
    Dim Fig1$
    Dim Fig2$
    Dim i
    Dim Str2$
    Dim Str1$
    Fig1$ = "QRBNK"
    Fig2$ = "DTACR"
    For i = 1 To 5 Step 1
    If Mid(Fig1$, i, 1) <> Mid(Fig2$, i, 1) Then
    Str2$ = Mid(Fig2$, i, 1) + "\1"
    Str1$ = Mid(Fig1$, i, 1) + "([a-h][1-8])"
    WordBasic.EditReplace Find:=Str1$, Replace:=Str2$, Direction:=0, MatchCase:=1, WholeWord:=0, PatternMatch:=1, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=1
    Str1$ = Mid(Fig1$, i, 1) + "([1-8a-hx][a-h][1-8])"
    WordBasic.EditReplace Find:=Str1$, Replace:=Str2$, Direction:=0, MatchCase:=1, WholeWord:=0, PatternMatch:=1, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=1
    Str1$ = Mid(Fig1$, i, 1) + "([1-8a-h]x[a-h][1-8])"
    WordBasic.EditReplace Find:=Str1$, Replace:=Str2$, Direction:=0, MatchCase:=1, WholeWord:=0, PatternMatch:=1, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=1
    Str2$ = "\1" + Mid(Fig2$, i, 1)
    Str1$ = "([a-h][1-8])" + Mid(Fig1$, i, 1)
    WordBasic.EditReplace Find:=Str1$, Replace:=Str2$, Direction:=0, MatchCase:=1, WholeWord:=0, PatternMatch:=1, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=1
    End If
    Next
    End Sub

    but if doesn't work in Expression Web 2.

    What is the equivalen expression for "WordBasic.EditReplace Find:=" etc.?

    Steve Easton

    As I said there is no SDK for EW and the best you can do is open the visual basic editor and then View > Obect Browser.

    I poked around and found the following Global constants:

    Const SearchActionFindText = 0
    Member of XWebPage.SearchAction


    Const SearchActionReplaceText = 1
    Member of XWebPage.SearchAction

    That should be a hint.

    Steve Easton

    I looked a little further and in the object browser click the down arrow by All libraries
    and select EXWebPages.
  • In the list that appears scroll down to SearchAction and SearchInfo.


    That should be the info you need.

    After it is completed and saved you can add your Macro to a button on the toolbar if desired.

  • Fer Morfer

    Thanks a lot for all the hints!

    I have found an interesting site in http://www.softpanorama.org/Office/Frontpage/frontpage_macros.shtml

    Best regards,

    Fernando

    Christoph Schneegans
    xWeb's Search and Replace feature supports regular expressions, but the syntax differs from the one used e.g. in JavaScript or .NET.

    Try to use Q{[a-h]} in the Find expression, and D\1 in the Replace expression.

    Recommended Links

    Microsoft Resources

    General

    Groups

    Microsoft Articles and How-to documents

    See vbafp4.chm and vbafpom4.chm files for reference topics covering all FrontPage object model language elements, as well as topics such as "Creating Web Sites Programmatically." The default installation path for these files is C:\Program Files\Microsoft Office\Office\1033.

    More Support & Troubleshooting results Technical Resources SDKs, resource kits, reference libraries, script centers, white papers, technical articles, product documentation...


    FrontPage Publishing with Visual Basic for Applications (Microsoft FrontPage 2002 Technical Articles)

    Visual Basic (VBA): Securing Microsoft Office Documents

    This chapter discusses how to preserve the integrity of code in your solution by restricting access to the code.

    http://www.microsoft.com/technet/prodtechnol/office/office2000/proddocs/opg/part4/ch17.asp

    Macros by Stephen C. Travis

    FrontPage Macros by Stephen C. Travis

    All Files - create a table at the cursor location containing a list of all files in the web and their properties (similar to the 'All Files' report).
    Sort Table - sorts a table in Normal View on the column and beginning in the row that the cursor is located.
    Breadcrumb Trail - creates a breadcrumb trail from the FrontPage navigation structure.
    Outline - automatically numbering heading tags (eg. 1.1.2 for an H3 tag).
    Navigation Tree - creates an indented list from the FrontPage navigation structure.
    Screen Tips - creates a <span> tag and title attribute for selected text.
    css Position - moves an object to the document body and places it inside an absolute positioned <div> tag (Used to change your page from HTML layout to CSS2 layout).
    Make VBScript - convert the HTML on a page to VBScript Document.Write statements.

    Microsoft FrontPage SDK

    Two SDK are available: FrontPage 200 SDK and FrontPage 2002 SDK.

    Download details FrontPage 2002 Software Development Kit (SDK)

    Microsoft FrontPage 2000

    Summary: MSDN Library - Microsoft Office 2000 Developer Object Model Guide. Excerpt: Microsoft Office 2000 Developer Object Model Guide Microsoft FrontPage 2000 Default location: \Program Files\Microsoft Office\Office Source (Type Library) The Microsoft

    FrontPage Interactions

    http:// msdn.microsoft.com / library / officedev / fp2ksdk / frontpageinteractions.htm

    Summary: MSDN Library - Office Developer Documentation - Front Page 2000 SDK. Excerpt: FrontPage Interactions Wizards communicate with FrontPage using the FrontPage Visual Basic Object Model described in the FrontPage Visual Basic Help.

    The FrontPage Editor Interface

    Summary: MSDN Library - Office Developer Documentation - FrontPage 98. Excerpt: The FrontPage Editor Interface The FrontPage Editor is a WYSIWYG web page editor for HTML documents. Web pages are stored in .htm or .html files on the web server.

    The FrontPage To Do List Interface

    Summary: MSDN Library - Office Developer Documentation - FrontPage 98. Excerpt: The FrontPage To Do List Interface The FrontPage To Do List is a flexible grid-like object that manages and displays a list of tasks to be performed on the web currently opened by the FrontPage Explor

    Web Workshop - FrontPage: Creating Page Backgrounds and Watermarks

    Summary: Creating page backgrounds and watermarks in Microsoft FrontPage

    Web Workshop - FrontPage: Establish Passwords that Protect

    Summary: Use FrontPage to establish passwords that protect

    Web Workshop - FrontPage: Designating a Custom Form Confirmation Page

    Summary: Designating a custom form confirmation page in FrontPage


    Tutorials

    Other tutorials

    [Jul 14, 2010] Automating Repetitive Tasks in FrontPage 2003

    In FrontPage 2003, FrontPage 2002, and FrontPage 2000, you can search for and replace text in HTML pages in two ways. One way is by using the SearchInfo object, which was added in FrontPage 2003. The other way is to use the IHTMLTxtRange object.

    Using the SearchInfo object, you can create customized, conditional searches that look for code in specific instances. For example, you can replace all B elements with I elements inside TD elements only. To do this, you use a query string that adheres to a defined XML schema. You can also specify a query string that finds and replaces text by using a regular expression. The first example below shows how to use the SearchInfo object. For more information, see Extending Find and Replace for Microsoft Office FrontPage 2003.

    In versions prior to FrontPage 2003, you can use the IHTMLTxtRange object to perform full text search and replace. The FindInFrontPage function in the second example below uses the findText method of the IHTMLTxtRange object to locate an instance of the specified string in the specified page, and then either inserts the string or replaces the specified string with another string. The function returns a Boolean representing whether the function found the search string and successfully added the text.

    The objects used in these examples are as follows:

    Finding and Replacing Text Example 1

    Sub QueryContents()
        Dim objSearch As SearchInfo
        Dim objRange As IHTMLTxtRange
        Dim objLimits As IHTMLTxtRange
        Dim strQuery As String
        Dim blnFoundMatch As Boolean
    
        'Create a query to find a TD element and
        'add an align attribute to the tag.
        strQuery = "<?xml version=""1.0""?>" & _
            "<fpquery version=""1.0"">" & _
            "<find tag=""b"">" & _
            "<rule type=""insideTag"" tag=""td"" />" & _
            "</find>" & _
            "<replace type=""changeTag"" tag=""i"" />" & _
            "</fpquery>"
    
        Set objRange = ActiveDocument.body.createTextRange
        Set objLimits = ActiveDocument.body.createTextRange
        Set objSearch = Application.CreateSearchInfo
    
        objSearch.Action = fpSearchFindTag
        objSearch.QueryContents = strQuery
    
        Do
            blnFoundMatch = Application.ActiveDocument.Find(objSearch, objLimits, objRange)
        Loop While blnFoundMatch = True
    End Sub

    Finding and Replacing Text Example 2

    Function FindInFrontPage(ByRef objTargetPage As PageWindow, _
            ByVal strFind As String, ByVal blnMatchCase As Boolean, _
            ByVal blnFindWholeWord As Boolean, ByVal strText As String, _
            ByVal blnInsert As Boolean) As Boolean
    
        Dim objBody As IHTMLBodyElement
        Dim objTextRange As IHTMLTxtRange
        Dim blnFound As Boolean
        Dim lngFlags As Long
    
        Set objBody = objTargetPage.Document.body
        Set objTextRange = objBody.createTextRange
    
        FindInFrontPage = False
    
        If blnMatchCase = True Then lngFlags = lngFlags + 4
        If blnFindWholeWord = True Then lngFlags = lngFlags + 2
    
        objTextRange.collapse True
    
        Do
            blnFound = objTextRange.FindText(String:=strFind, _
                flags:=lngFlags)
    
            If blnFound Then
                If blnInsert = True Then
                    objTextRange.collapse False
                End If
                objTextRange.Text = strText
                FindInFrontPage = True
                Exit Function
            End If
        Loop While blnFound = True
    
        Set objBody = Nothing
        Set objTextRange = Nothing
    
    End Function
    
    
    'Use the following subroutine to call the preceding function.
    Sub CallFindInFrontPage()
        Dim blnFound As String
        Dim objPageWindow As PageWindow
    
        Set objPageWindow = Application.LocatePage( _
            DocumentURL:="example.htm", ViewMode:=fpPageViewNormal)
    
        blnFound = FindInFrontPage(objTargetPage:=objPageWindow, _
            strFind:="text to find", blnMatchCase:=True, _
            blnFindWholeWord:=True, strText:="text to add or replace", _
            blnInsert:=False)
    
        Select Case blnFound
            Case True
                MsgBox "Search text found and new text added successfully."
            Case False
                MsgBox "Unable to locate search text."
        End Select
    
    End Sub
    

    Inserting an Interactive Button

    In FrontPage 2003, you can programmatically add interactive buttons to Web pages using the InsertInteractiveButton method of the FPHTMLDocument object. The following example adds the "Glow Capsule 1" button. When you add an interactive button to a Web page, FrontPage inserts the necessary scripts. When you remove an interactive button from a Web page, FrontPage removes the scripts.

    The objects used in this example are as follows:

    Inserting an Interactive Button Example

    Sub InsertNewButton()
        Dim objSelection As IHTMLTxtRange
    
        Set objSelection = ActiveDocument.Selection.createRange
    
        ActiveDocument.InsertInteractiveButton objSelection, "fp-btn:Glow Capsule 1", _
            "Home", 200, 50, "http://www.microsoft.com", "_blank"
    End Sub
    

    Random Findings

    Klemid's tools Fav2Web

    Extending Find and Replace for Microsoft Office FrontPage 2003


    Etc

    Society

    Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

    Quotes

    War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

    Bulletin:

    Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

    History:

    Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

    Classic books:

    The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

    Most popular humor pages:

    Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

    The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


    Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

    FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

    This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

    You can use PayPal to to buy a cup of coffee for authors of this site

    Disclaimer:

    The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

    Last modified: March 12, 2019