Skip to main content
CRMSalesforce CRM

Open Visual Force Page in Microsoft Word

By December 27, 2020No Comments

Having a visual force page open in Microsoft Word can come in handy for mass mail merges, labels, and templates.

When creating your visual force page, add the following to top <apex:page> section:

<apex:page standardController=”Account” contentType=”application/msword#FileName.doc” showHeader=”false” standardStylesheets=”false” > 

ContentType controls the application that will open the page.  Be sure to include showHeader = “false” and standardStylesheets=”false”.

Next, add a header and style section:

<head>

<style type=”text/css”>

        @page Section1{

            size:8.5in 11.0in;

            mso-page-orientation:Portrait;

            margin:2.5in 1.25in 1.0in 1.25in;

            mso-header-margin:.5in;

            mso-footer-margin:.5in;

        }

        div.Section1

        {

             page:Section1;

        }

        body {

            font-family:”New Times Roman”;

        }

</style>

</head>

This will set the Word document formatting such as margins, headers and font.

Finally, add a <div class> so that everything will be included with the Word format.

<div class=”Section1″>

                YOUR PAGE CODE HERE

</div>

</apex:page>

Test the page and see if it will open automatically in Word (newer versions).  Otherwise it will download and then click to open it.  You may have to set the view to Print Layout and Enable editing.

 

Becci MG

Author Becci MG

More posts by Becci MG

Leave a Reply

5 Great Alternatives to SalesForce.com

Free Whitepaper Download

Learn more about 5 options that are better CRMs for small business

DOWNLOAD WHITEPAPER

Skip to content