CENTERING THE 2002 Pub pages - invitation for suggestions

S

Stevan

Hi all, I just read all of your comments in the "How to center the webpages
in the screen" thread. I found the comments interesting especially since I
had asked the same question some time ago, without realizing that it was
such a debated issue.

So, seeing that I have not tried centering my pages yet, and seeing that I
would like to indeed prefer for my page to be centered, can you please
suggest to me which codes I need to use and exactly where so that my pages
will be centered in the browser, without any of my page features shifting
away from where they currently are. I think I tried one of the suggested
codes just once and it shifted my "intermittently ringing clock" to the
right of the page.

If you offer a suggestion, would you mind showing me exactly how the
inserted code should look using the code that is already there? It would be
nice if I did not have to open up every page (I have just over 80 of them)
individually just to insert the code. My website is
http://www.TimesaversForTeachers.com I have one or two more questions
regarding the implementation of features that I have not done successfully
in the past but for now, I think I will carefully read all of your
suggestions regarding the code. I am currently using Publisher 2002.

By the way, I find the responses (by David, Eric, Don, Maureen, Rob, etc.,)
very useful and interesting and the disagreements very amusing.... so
amusing that I just had to read all of the recently written threads :) Thank
you all for making my infrequent visits to the forum more interesting than
expected :)
 
D

Don Schmidt

Stevan,

This works very well and I use it on my www.vanusa.org site built with
Publisher 2000.

=====================================================
A Donald Canned Response -
Centering Publisher 2000 & 2002 webpages:

This works only for websites created with Publisher 2000 & 2002.
There are other fixes for other versions of Publisher; see below.

Each of your html files requires adding the <center> code after the
existing </head> code.

You can go into each html file and do it manually or get the free
ReplaceInFiles program and make it an easy chore.


"ReplaceInFiles" can be downloaded from:

<http://www.emurasoft.com/index.htm>

The four boxes require the following information:

Find: </head>
Replace with: </head> <center>
File Types: *.html
In Folder:
(use the button to go to the folder where the html files are located
on your hard drive)

The bottom four boxes can be left blank.

Note: Once the boxes are filled out and the "Replace all" is selected,
the entries are retained for the next time you use the program.

Don - www.vanusa.org
------
Vancouver, USA

P.S. One of the kind visitors of this news group told us of
ReplaceInFiles program some time ago;
'Sorry I forgot the individual's name. (Another unsung hero).

=====================================================
 
D

DavidF

Stevan,

Glad you have found it all amusing...not sure that is the way I would
characterize it.

What is the exact width of your pages?

DavidF
 
E

Eric James

In the case of your pages you can centre them with the simple addition of a
few css tags - there is no need to insert any html, let alone break the
document structure by doing so. Taking the front page as an example, just
tweak the following two lines, found not far from the top of your file:

<body link=blue vlink=purple style='margin:0'>
<div style='position:relative;width:8.5in;height:48.0in'>

to make them look like this:

<body link=blue vlink=purple style='text-align: center; min-width: 820px;'>
<div style='position:relative;width:8.5in;height:48.0in; width: 820px;
margin: 0 auto; text-align: left;'>

and you are done.
I've put in a value of 820px for your page width - this fits your front page
but if any pages are wider you may need to stretch it a bit more.
If you found my earlier post, that amounted to exactly the same thing,
except I attempted to make it a little more general purpose fit for any
page.
This is a very widespread and commonly used method - type "css web page
centering" into Google and you will find literally hundreds of explanations
and examples of how to do it, some better than others, obviously.
As for having to perform this tweak in every page - unfortunately that is
one of the many drawbacks of using Publisher.
CSS styling is also far more powerful if the css is divorced from the page
content by placing it in a separate file which is then referenced by every
page which uses it. It then becomes possible to make global changes to any
aspect of layout or style throughout your entire web site by simply editing
one file. It is consequently much easier to achieve a consistent layout and
style across any number of pages, as definitions and changes only need to be
made once, in one place. So, if you want to change some colours, fonts,
backgrounds or whatever across your entire site, it becomes a five minute
job instead of a three hour one. Also, when the pages themselves are no
longer cluttered by styling and layout markup, it becomes much easier to
maintain and change the actual content. In addition to that, the loading and
display of pages within browsers is much more efficient and faster as the
styling information is cached and does not need to be downloaded and
reprocessed with every page, and the code is considerably more compact.
There are countless resources on the web explaining how to do all this, and
I would especially recommend Eric Meyer's books on CSS
(http://www.ericmeyeroncss.com/) if you would like to pursue this further
(Do a "View->Source" in your browser on the above page and compare and
contrast to all the rubbish found in a Publisher page!)
 
R

Rob Giordano [MS MVP]

gotta love the print metrics publisher uses though....width:8.5in

--
~~~~~~~~~~~~~~~~~~
Rob Giordano
Microsoft MVP Expression
 
E

Eric James

& of course what I forgot to add was that the "width:8.5in;" bit should
really be deleted, as there shouldn't really be two width definitions, in
different units, in the same tag - even if they do equate to roughly the
same actual width.
At the risk of really really confusing David.... try dividing 820px by 8.5in
and there's a thing - it's 96dpi!
 
R

Rob Giordano [MS MVP]

well, I'm not gonna pick on DavidF, but...

I really hate to see people wasting time following a path that leads
nowhere. I seriously doubt that Publisher will ever be updated to produce
valid html, and spending gads of time with work-arounds like centering pages
is insane (btw, you have to apply the work around EVERY time you update your
pages because Publisher will undo what you did before).

btw...I use Publisher a LOT for what it is intended to do; dtp. I think it's
an underrated program for dtp. I've experimented with it for web pages
trying to help here but that's about it.

--
~~~~~~~~~~~~~~~~~~
Rob Giordano
Microsoft MVP Expression
 
E

Eric James

I would wholly agree... and might even go a bit further in saying that
Publisher 2000 anyway is ok for making web pages out of material originally
designed for print - if the print was done in Publisher of course, and I
have done a lot of that. (Am gradually converting all the web versions to
pdf now... but Publisher seems ok for that too, which is handy. This has now
become a preferred method for us because search engines are now much better
at fishing around in pdf files on web sites than they were ten years ago -
things move on.)
It has annoyed me though that Microsoft make almost zero effort in fixing
any of the bugs in it nowadays - and even wilfully carry them on from one
version to the next. Even very simple ones like text boxes not showing an
overflow indicator if they're too small and the text is only one line...
That's why I think it's longer term future looks a bit dubious.
 
D

DavidF

Stevan,

Sorry I haven't had time to reply. My work week has been especially busy and
I didn't have time to respond to you or to help answer any of the other
questions for the last few days.

Congratulations. You have the dubious honor of being the first Pub 2002 user
that has posted and said that the centering code we use for Pub 2000 webs,
didn't work for your Pub 2002 site. Another Pub 2002 user had told us
sometime in the past that it did work, but apparently it doesn't work all
the time.While neither Don or I have Pub 2002 installed and can't test and
verify this, I think we will have to change the boilerplate answer he and I
and Spike give for centering questions in the future. Thanks for the
feedback.

Given that I do not have Pub 2002 installed, I can't say for sure whether
your experience is unique to your web publication or more general. However,
I copied your source code for your home page, and manually edited the code
with NotePad, and wasn't able to get the Pub 2000 centering code to work
either. The good news is that I was able to get the centering code string we
use for Pub 2003 and 2007 to work. In fact, it appears from a couple quick
tests that it also works in Pub 2000 webs. Once again, I was only using your
source code and thus I didn't have the embedded images, and it is possible
that it won't work for you. However, I will share the code string that I
found worked, and you can test it yourself.

------------

</head><table border="0" cellpadding="0" cellspacing="2"
width="833"align="center"><tr><td>

------------

It worked in IE, FF, Opera, Safari, and Chrome. And since your clock image
is imported I was able to confirm that it was centered. The placeholders for
the other images that you embed all seemed to be in the proper place.

The reason I wanted to know how wide your pages are, is the code includes
the page width in pixels. If you don't use the pixel width of the page, the
page will not be perfectly centered in the browser window. It will be offset
somewhat. I approximated your home page at 833 pixels wide, or ~22 cm or
~8.7 inches.

You can either post the width of your pages, and I will use Pub 2003 or 2007
to calculate the pixel width, or you can probably calculate it yourself.
Publisher outputs the html web pages at 96 ppi, so for example, if your
publication page is set up as a 7.5 inch page, you will get a 720 pixel wide
web page (96 X 7.5). If you are using centimeters, the conversion may not be
so exact, so feel free to post that number and I will use Publisher to
calculate the pixel width.

You can test this code string yourself. If you aren't doing so already,
publish your webfiles to a folder somewhere on your local computer where you
can easily find them. Now go to that folder and find the index.htm file >
right click > open with > NotePad. Or just double click the index.htm file
which will open it in your default browser > View >
Source. Then in NotePad go to Edit > Find and paste:

</head>

in 'Find what:' and it will take you to where </head> is located in the
source code. Now replace </head> with the code string:

</head><table border="0" cellpadding="0" cellspacing="2"
width="833"align="center"><tr><td>

Close NotePad and save the changes. Go back to the index.htm file, double
click and preview the page in your browser. It should be centered.

Assuming that this works for you on your home page, I suggest you test one
other page at this point. Your 'About Author' page:
http://www.timesaversforteachers.com/index_page0003.htm seems to be wider
than 833 pixels. While the code string seemed to work in the source code for
the page, the large images were embedded in your publication and so I could
only see the placeholders in the test I did. If this page is wider than 833
pixels, you might find that the page is not perfectly centered. You might
have to change the layout such that it all fits on your standard size page
in order to get a perfect centering, or you may find it close enough. Once
again, not having your actual publication, or Pub 2002 installed makes it
impossible for me to say for sure.

I obviously didn't take the time to test each of your pages. And while you
may need to adjust the layout of some pages in order to get 'perfect'
results, I think you should get generally good results once you change the
width in the code string to the standard pixel width of your publication
pages.

Now as you just discovered, manually editing the source code of each page of
a Publisher web is neither desirable or practical. Publisher is designed
such that if you want to make any changes in your web pages, you must go to
the original Publisher publication, make your changes and then produce new
web files and upload those to your host. It simply isn't practical to
manually edit the html code in one page let alone 80 pages as in your case,
each time you want to update your website. So even though the 'proper' code
for centering a Publisher 2000 web page has been known for many years, it
was rarely used. Publisher users simply did not want to have to manually
edit each page of their site every time they updated. However the centering
question kept coming up and members of this group kept looking for an easy
and practical way to center Publisher pages.

The breakthrough came when someone, and that may have been either Don or
Spike, came across a free, little utility called "ReplaceInFiles" which you
can find at http://www.emurasoft.com . This little program made it possible
to replace one line of code with another line of code in all the Publisher
2000 .html files 'automagically'. You did not need to open each .html file
and edit the code manually. Initially we ran the utility twice to replace
both the <head> and then the </head> tags with the 'proper' code. Then
through trial and terror it was discovered that it wasn't necessary to
replace the <head> tag...that replacing the </head> tag with '</head>
<center>' was all that was necessary to get Publisher 2000 web pages to
center in browser windows. Those of us that used Pub 2000 found that after
we set up ReplaceInFiles the first time that from that point on it required
only two clicks to automagically edit the new html code we produced each
time we wanted to update our sites. Click once to open ReplaceInFiles and
once to click the 'Replace All' button and the web files were ready to be
uploaded to the host. Woohoo! We had an easy, practical way to center our
pages, and quite honestly we didn't care that we were not using 'proper'
coding techniques or syntax...we were just glad that it worked.

However, the centering code we used for Pub 2000 pages didn't seem to work
for the newer versions of Publisher as the html coding engines had been
changed and produced different code. Time passed and an unknown Pub 2002
user told us that the code we used for Pub 2000 worked for them, so we added
that to our boilerplate answer. Intermittently someone would suggest some
code for Pub 2003 and 2007 but it either didn't work, or it couldn't be
reduced to one line of code which was necessary to use ReplaceInFiles.
Finally a person named Jo posted some code that did work in Pub 2003 and
2007 but it was again multiple lines of code and again required that both
the <head> and the </head> tag be edited in two steps. Then once again
through trial and terror we discovered that we didn't need to use all the
code she posted, and that we could combine most of the code into one line,
and replace just the </head> tag and that is how we came to use the current
centering code posted in the boilerplate. And once again, we didn't care
that the code was not 'proper'...just that it worked and was a practical,
easy way to center Pub 2003 and 2007 pages.

Our methods of centering Publisher 2000, 2003 and 2007 web pages do not use
'proper' code, but thus far no one has found this code to not work in any
Publisher web or in any browser. Until you, no one had told us that it
didn't work for Pub 2002, but it appears that the Pub 2003 and 2007
centering code does work in Pub 2002. You can test the code string I
provided and if it works, then use ReplaceInFiles to easily and
automagically edit your code so that your web pages will be centered...or go
a different route. Your choice...

You can save time and skip the manual test I proposed if you want, and just
test the code using 'ReplaceInFiles'. If you do, you can follow the basic
instructions that Don gave with a couple differences. I will paste a
modified version of his instructions below with some additional instructions
for you and for Pub 2003 and 2007 users.

-----------------

The four boxes in 'ReplaceInFiles' require the following information:

Find: </head>

Replace with: </head><table border="0" cellpadding="0" cellspacing="2"
width="833"align="center"><tr><td>

(Note that the code string will wrap in these instructions, and must be just
one line in this box. I use NotePad to prepare the code string and then just
copy and paste it.)

File Types: *.htm

(Note that Pub 2000 produces *.html files by default. You are using *.htm
files and that is also the default for Pub 2003 and 2007.)

In Folder:
(Use the ... button to browse to the folder where the Publisher *.htm files
are located on your hard drive.)

The bottom four boxes can be left blank for Pub 2000, but if you are using
the 'organizing folder' option in Pub 2003 and 2007. You should check
'Replace in Subfolders' so the *.htm files in that 'organizing folder' (the
'index_files' folder) will also be edited.

Once the boxes are filled out and the "Replace all" button is selected, the
entries are retained for the next time you use the program. This also means
that you should choose a permanent folder location on your hard drive to
direct your web files to each time you publish new web files from Publisher.
Then it is a matter of opening 'ReplaceInFiles' and clicking the "Replace
all" button and your web files are ready to be uploaded to your host.

--------------

So there you go. A long winded suggestion for a method of centering your Pub
2002 web pages. As you found some of the other recent posts useful,
interesting and amusing I decided you might appreciate the historical
perspective of how the centering workaround evolved. If you decide to try it
please post back and let us know if it worked for you. I would like to test
your pages in the different browsers to confirm that there is no problem
there, and if it all works as expected we will change our boilerplate
instructions accordingly. Thanks for letting us know that the centering code
did not work for your Pub 2002 pages, and contributing to the evolution of
our centering code solution. Hopefully in the next version of Publisher MSFT
will build-in the option of centering pages, and the arguments about these
workarounds and how 'proper' they are will become moot.

DavidF
 
E

Eric James

it either didn't work, or it couldn't be
reduced to one line of code which was necessary to use ReplaceInFiles.

The more rational among us might just wonder why one wouldn't just look for
a better solution than ReplaceInfiles, wouldn't they?
Two minutes or less spent using Google might lead you to this:
http://www.ecobyte.com/replacetext/ among many others, which can insert
multiple lines of text and is much more flexible in numerous other ways.
And once again, we didn't care
that the code was not 'proper'...

And evidently, still don't.

Quite why David prefers not to spend ten seconds using Google to find a
solution which works, is used on hundreds of thousands of web sites, and is
'proper' instead of spending days working out another incorrect solution is
quite beyond me.
He might even have found this: http://support.microsoft.com/kb/195094 which,
before distortion by Chinese whispers and a general lack of understanding,
is possibly the true root of the erroneous 'solutions' parrotted here. (The
reader should bear in mind this was written well before css became the
preferred method of achieving styling & layout, and it may not work now
because the "center" tag has been deprecated for years and such tags can be
and are overridden by css code elsewhere).
 

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