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 Customization

News

See also

Books

Recommended Links Keyboard shortcuts FrontPage Macro Programming
FrontPage 2003 Cheat sheet Working with HTML DOCTYPE Declarations in FrontPage Search & Replace Code Snippets in FrontPage 2003 Humor Etc

Initially, FrontPage's short menus only display the standard commands, and, as you work, the program automatically adds the commands you use most often. If you don't like this automatic customization, you can turn it off by selecting Tools/Customize, clicking the Options tab, and deselecting Menus Show Recently Used Commands First.

You also can choose how to customize the menus and toolbars. Click the Commands tab of the Customize dialog box to display all the commands available within FrontPage. Drag and drop commands from the Customize dialog box onto the menu or toolbar of your choice. To create a new toolbar, choose Tools/Customize, click the Toolbars tab, and click the New button. Type a name for your new toolbar and then simply drag and drop whatever commands you want on to your new toolbar from the Commands tab.

There are several FrontPage customizations that help you to reach maximum productivity:

There are two hardware peaces that are also important: 24" display (or better two or three) and programmable keyboard with programmable mouse. (see Usage of programmable keyboard and high end mice below)

Make a macro button

One of the best new features of FrontPage 2000 is the Visual Basic for Applications Macro Editor. Macros can be a great help in applying a number of repetitive tasks. The only problem is that after you create a macro you have to go through a series of menus just to access it, which defeats the purpose of the shortcut. Expanding a bit on the previous tip, FrontPage will let you create your own custom macro button.

Select Tools/Customize and click the Commands tab. Click the Macros category and then drag and drop either the Custom Menu Item command to a menu or the Custom Button command to a toolbar. Right-click the command. On the pop-up menu type in a new name for the command, then select Assign Macro. Choose a macro from the Macro dialog box, and you've got your new macro button. You also can change the icon for the button by right-clicking it and selecting either Change Button Image or Edit Button Image. Change Button Image displays a selection of 48 premade icons from which you can choose. If you don't like any of those, the Edit Button Image function will let you actually create one of your own.

Create your own commands

FrontPage 2000 now includes support for the Visual Basic for Applications (VBA) language, which has become so popular because of its widespread use in Microsoft Office. With VBA, you can automate tasks, manipulate different aspects of your Web project within the VBA programming environment, and create your own commands. As an example, here's how to add a Save All command to FrontPage that will allow you to save every open page in a project with just one click.

First, start the Visual Basic Editor (VBE) by selecting the Tools/Macro/Visual Basic Editor menu. Insert a new module by selecting the Insert/Module menu. In the Properties window (located on the left side of the VBE window), change the name of the module to SaveAll. Now, in the module code window that opened up when you inserted a new module, type this code :

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

To add the new command to the File menu in FrontPage, choose Tools/Customize to open the Customize dialog box. Under the Command tab, select Macros from the Categories list. Drag the Custom Menu Item item from the Commands list onto the FrontPage File menu and drop it beneath the Save command. Next, click the Modify Selection button in the Customize dialog box, and a context menu will appear. Type Save All in the Name field and then select Assign Macro. In the Macro dialog box, select the Save_All macro and click OK. Close the Customize dialog box, and your new Save All command appears in the FrontPage File menu.

4. Teach FrontPage to format your code
You can tell FrontPage how you like your code, and it will format it automatically. By providing a sample file, you can specify if you'd like your code indented, your tags capitalized, and so on. Open a sample page that contains code formatted the way you prefer (the more tags in your sample page, the better). Then select Tools/Page Options and click the HTML Source tab. Click the Base On Current Page button, and FrontPage will set its formatting rules accordingly. Then select the Reformat Using The Rules Below option, and every page you load and save will be formatted like the sample file.

(Note: Special thanks to Tricia Fahey, Gretchen Tosh, and the FrontPage Development Team for all of their expertise.)

Scott R. Garrigus is an author, musician, and all-around, multimedia guru. In addition to his frequent contributions to CNET Builder.com, he publishes his own e-zine called Comp-media. 

Working with Microsoft FrontPage Objects

Microsoft FrontPage is new to the Office suite of applications and is available in Microsoft Office 2000 Premium. FrontPage is a powerful and popular application used to create, deploy, and manage Web sites. You can also use FrontPage to create individual Web pages or modify existing Web pages.

FrontPage 2000 now supports the Visual Basic Editor and VBA. In addition, to enable you to work with the various parts of a FrontPage-based web or a Web page, FrontPage now exposes a complete object model that you can use either from within a FrontPage VBA project or from another application through Automation. The new VBA language elements replace the FrontPage 98 language elements. To ensure backward compatibility, the FrontPage 98 language elements are included as hidden elements in the FrontPage 2000 object model, but these language elements are not recommended for use in FrontPage 2000.

Note   You can view the FrontPage object model in the Object Model Guide. You can also use the Object Browser and Microsoft FrontPage Visual Basic Reference Help to learn more about individual objects, properties, methods, and events. For more information about using VBA to work with an Office application's object model, see Chapter 4, "Understanding Office Objects and Object Models."

Although all Office applications support VBA, it is used a bit differently in FrontPage and Outlook than it is in the other Office applications. FrontPage and Outlook support a single VBA project that is associated with a running instance of the application. The other Office applications let you associate a VBA project with each Office document. For example, you can have several workbooks open in Excel at one time, and each workbook can have its own VBA project that contains modules, class modules, and UserForms. In FrontPage, you can have several webs or Web pages open at one time, but there is only one VBA project. The FrontPage VBA project is stored in a file named Microsoft FrontPage.fpm in the following locations:

This section discusses how to work with commonly used FrontPage objects and their related methods and properties, but it does not provide a complete discussion of the FrontPage object model. You can get more information about the objects, methods, and properties in the FrontPage object model by using Microsoft FrontPage Visual Basic Reference Help in the C:\Program Files\Microsoft Office\Office\1033\Vbafp4.chm file.

Note   The path to the Vbafp4.chm Help file reflects the language ID folder (1033) for U.S. English language support in Office. The language ID folder below C:\Program Files\Microsoft Office\Office differs for each language.

FrontPage2000/2002 Macros - Getting Started

That's actually the difficult bit - getting started.  If you're reading this, you already know the documentation is useless, and worse than useless.  So, what do we want to do, and how do we want to do it?

What I wanted to do was to add verse numbers to a Latin text, without having to type them all, in the format [1] ... [2] ... etc throughout the text.  I wanted to stick the cursor at the start of the right sentence, and press a key and get the [n] inserted.  I wanted the number to increment automatically every time I hit the same key; and to reset back to [1] when a new chapter started.  

Obviously the number would be a public global variable, set by two macros.  But how to code it?

This is bad enough to find out about in Word.  It's worse in FP2000, and the code won't work across both platforms (thank you, Microsoft).

[Note: These instructions also work in FP2002.  If you install FP2002 without removing FP2000, the macros are preserved, but you have to recreate the toolbar entries.  The process is marginally more obvious in FP2002, but not much, and the following instructions still work.]

[Why did I upgrade?  I found that the editor in FP2000 does not reliably handle unicode.  If you enter

<font face="Code2000,TITUS Cyberbit Basic"><font size="6">&#1808;&#1810;</font>

in FP2000, you get an empty square --  in FP2002, and in Dreamweaver 6, you get the correct character displayed (these are Syriac, if you're interested -- the Greek unicode entries work OK).  In both FP2000 and FP2002, the Preview works -- but of course I wanted to enter text wysiwyg].

1.  Creating a Macro

I presume you did open FrontPage?  I don't use webs, so you needn't worry about them.  From the menu, choose Tools|Macro|Macros.  This gives the screen

(This will be blank when you start - these are my three macros). Type in a name, and the 'Create' button will become active.  Click it, and you'll be placed in the Visual  Basic editor in a sub of the name you chose.  If you want to check things are OK, try this

public sub test()
   msgbox "hello"
end sub

as your first test.  Save the macro.

'Where is it saved?' I hear you cry.  There is a "Microsoft FrontPage.fpm" file somewhere on the system (the location varies with Windows version - thank you, Micro$oft), and they are saved in there.  So they will be available in every document automatically, but of course are not included in the documents themselves.

2.  Running a Macro

Remarkably, Microsoft have managed to make this difficult.  The simple way (and the one suggested in all the documentation, which tells you no-one outside the development team reviewed that documentation) is to load that screen above (Tools|Macro|Macros, or Alt-F8), highlight the macro, and press run.  Not exactly something you want to do 3 times a second, is it?

Of course in MS Word, you'd assign it to a hot-key.  Well, forget about that right now - they haven't made that possible!  But you can get round this a certain amount, as they will allow you to create your own menu items and toolbar items.  The index gives no help unless you know the magic words to look for.  The one to look for is 'view or customize toolbars'.  This will tell you (inadequately) how to add a new icon to the toolbar.  The process is much better described on Robert Robbins page which I will not duplicate here - print it and follow the instructions.  

Note that you can remove any icons by View|Toolbars|Customize|Toolbars, selecting the toolbar you've messed up, and pressing Reset.

What the tutorial does not tell you is that the same process can also be used to add Menu items.  This means you can use the keyboard to help you.  If instead of choosing a toolbar icon, you ask for a new menu item, you can drop it in the top menu bar.  Make sure you include an & in the name, as that will allow you to use a hot-key.  So I named my top level menu '&Macros', which means that Alt-M will pop it up.  Then you have to add items to the menu.  Each of these will, of course, be a macro.  Again you make sure the name has '&' in it, so you can simply press a single letter once the menu is open to run the macro.

And there you have it.  So I can run macro A (which I called &A when prompted for a name) by Alt-M, A.  That's almost as good as hot keys.

While I was writing, Robert Robbins has just emailed me a better way (thank you!):

"To create a hotkey you must select "Image and Text" for the button and then enter a button name. The first letter of the button name will be the hotkey ALT + letter. But you should pick a letter that is not being used for a menu item."

Note: Error 70, Permission denied

If you try to run a macro which inserts in a page with the document open in HTML mode rather than Normal mode, you get an error 70, Permission denied.  This happened to me when I was debugging, and I wondered what the problem was.

3.  Writing text into your document from a Macro.

You won't find out how to do this from the documentation.  However it is fairly simple.

Sub test()
  '-- Your cursor position, as in MS Word, must be treated as a 'selection'.   
  Dim myRange As IHTMLTxtRange

  '-- ActiveDocument is the page you have open.  Selection is either a selection highlighted on the screen
  '-- or your cursor position / insertion point.  This is a strange way to do things, but they do it in Word also.
  Set myRange = ActiveDocument.selection.createRange
  '-- You can then stick some raw HTML in, and it will be inserted either instead of what you highlighted,
  '-- or after the selection point.  So the following will appear in Italics, rather than with chevrons in
  '-- the text.  Try it and see!
  myRange.pasteHTML ("<i>hello</i>")
  '-- Alternatively you may not want HTML, so you can just use the .Text method.
  'myRange.Text = "fred"

  '-- If you then want to change what you entered sky blue, you can do so... provided it's between HTML tags!
  '-- These are called the 'parent element' of your text.  Of course if you didn't specify any, you get whatever
  '-- is around - usually the whole paragraph - modified.
  '-- In our case, Parentelement being the <i>...</i> element/block
  myRange.parentElement.Style.backgroundColor = "SkyBlue"

End Sub

It's worth looking at the HTML that results, just so you know what happens.  It's OK - but I don't want that sort of inline Style stuff, myself.  I think I would not use the Style stuff at all, but code it myself.

4.  Navigating around the document

I haven't had to do this yet, so I haven't worried about it.  I can see, tho, that the ActiveDocument object contains all the tags, in order, and each tag contains text, etc.  So one could iterate through these in some way, I think, if you wanted some sort of Search and Replace.

My suggestion is to type in the object, and then look up in turn each of the methods and properties that intellisense supplies when you type '.' and wait.  As we have seen, the names mean nothing.  Who would have thought pasteHTML was 'insert after selection?'.

5.  Other thoughts

I hope that's helpful.  Remember you can save the macros out as .bas files from the VB editor, and import them.  Have fun - and if you find out anything useful, put it online for the rest of us!

6. FAQ

1.  Writing HTML around the selection

>What about writing html around the selection. Say I select the url and run a macro that puts:
>     <a href="http://www.kghvkhg.com">www.kghvkhg.com</a>
>this macro will have to use the selected region as a variable.
>
>how do I do this?

sub mySub

'-- Get the selection
Dim myRange As IHTMLTxtRange
Set myRange = ActiveDocument.selection.createRange

'-- Display the bit selected
MsgBox (myRange.Text)

'-- Change the bit selected
myRange.pasteHTML ("<B>" & myRange.Text & "</B>")

end sub

2. How do I find the insertion point?

> How do I find out where the cursor is in the page?
Dim myRange As IHTMLTxtRange
Set myRange = ActiveDocument.selection.createRange

If there is no existing selection, text written to myRange will be inserted at the cursor.  If there is a selection, the selected text will be overwritten.

3. How do I insert the contents of the clipboard into the text?

Sub InsertApparatusLink()
'-- Take the contents of the clipboard (the text for a #link) and apply as url to current selection

'-- Get text
Dim MyData As DataObject
Set MyData = New DataObject
MyData.GetFromClipboard
'-- Get the text into a string
Dim mystr As String
mystr = MyData.GetText(1)

'-- Get the selection/insertion point
Dim myRange As IHTMLTxtRange
Set myRange = ActiveDocument.selection.createRange

'-- Build the text
myRange.pasteHTML ("< A HREF=""#" & mystr & """>" & myRange.Text & "</A> ")

End Sub

4. How do I save the file and close it?

(Hooked it up to alt+q. -- This one by Carsten Engel)

Sub saveandclose()

'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
    activePage.Save
    activePage.Close
End If

End Sub

5. How do I change the name of all the <A NAME="fred bloggs"> to get rid of spaces as <A NAME="fred_bloggs">

There are various collections of the tags in the document model.  Do this one like this:

Private Sub RemoveSpacesFromAnchorNames()

Dim anchor
Dim i As Long

For Each anchor In ActiveDocument.anchors
   'MsgBox anchor.Name & " " & Replace(anchor.Name, " ", "_")
   'i = i + 1
   'If i > 5 Then Exit Sub
   anchor.Name = Replace(anchor.Name, " ", "_")
Next

End Sub

The commented out code I used before making the change to check that what I was seeing was right.  I didn't want the msgbox to keep popping up for every anchor in the document, as it had a lot of these!

The same method works for links/urls in the document:

Private Sub RemoveSpacesFromLinkNames()

Dim link
Dim i As Long

For Each link In ActiveDocument.links
    'MsgBox link.href & " " & Replace(link.href, " ", "_")
    'i = i + 1
    'If i > 5 Then Exit Sub
    link.href = Replace(link.href, " ", "_")
Next

End Sub

6. How do I sweep all text in the page?

Select a range which includes the contents of the <BODY> tags (HEAD and HTML are not supported):

Set myRange = ActiveDocument.all.tags("BODY").Item(0).createTextRange

Then use it like any other range, as above, and you can change any character, or apply formatting to the whole thing.

e.g.:

Private Sub EveryCharacter()

'-- Get the selection
Dim myRange As IHTMLTxtRange
Set myRange = ActiveDocument.all.tags("BODY").Item(0).createTextRange

MsgBox (myRange.htmlText)    '-- All the ASCII text, including tags, etc, all raw
MsgBox (myRange.Text)        '-- Just the text, not the HTML tags
'myRange.pasteHTML ("<B>" & myRange.Text & "</B>")   '-- Do something to the selected text

End Sub

7. How do I change the Title of the document?

Use/Set ActiveDocument.title.

8.  How do I emulate 'Paste Special'?

Carsten Engel sent me this:

Sub pastespecial()
  '-- Get text
  Dim MyData As DataObject
  Set MyData = New DataObject
  MyData.GetFromClipboard
  '-- Get the text into a string
  Dim mystr As String
  mystr = MyData.GetText(1)

  '-- Get the selection/insertion point
  Dim myRange As IHTMLTxtRange
  Set myRange = ActiveDocument.selection.createRange

  '-- Paste the text asif HTML
  myRange.pasteHTML (mystr)

End Sub

Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites



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