function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Tre PedigoTre Pedigo 

Help with visualforce word document rendering

Hello all,
I have rendered my visualforce page as a microsoft word document, so that upon going to it you are prompted to download the word file. The problem is that I have inserted this page into the "Opportunity" page layout, and now every time I go to a specific opportunity it prompts me to download the word document. Our sales team obviously doens't want to have to deal with this everytime they want to view an opportunity. Is there any way to edit my vf page so that it gives an option of downloading the displayed information as a word document, instead of what I have described above? My code is as follows:



<apex:page standardController="Opportunity" contentType="application/msword">

    <head>
        
    </head>
    <body>
        <center>
        <h1>Opportunity </h1>
     
        <apex:panelGrid columns="2" width="70%">
            <b> Opportunity Name: </b><apex:outputText value="{!Opportunity.name}" styleClass="companyName"/>
             <b>Sales Engineer: </b><apex:outputText value="{!Opportunity.Sales_Engineer__r.FirstName&" "& Opportunity.Sales_Engineer__r.LastName}" styleClass="companyName"/>
             <b>Sales Person: </b><apex:outputText value="" />
             <b>Related Account Name: </b><apex:outputText value="{!Opportunity.Account.name}" styleClass="companyName"/>
             <b>Building Square Footage: </b><apex:outputText value="{!Opportunity.Building_Square_Footage__c}" styleClass="companyName"/>
             <b>Subscription Term (months): </b><apex:outputText value="{!Opportunity.Subscription_Term_Months__c}" styleClass="companyName"/>
             <b>Total contract value: </b><apex:outputText value="{0,number,currency}" styleClass="companyName">
                                              <apex:param value="{!Opportunity.TCV__c}" />
                                          </apex:outputText>
             <b>Existing or New Construction? </b><apex:outputText value="{!Opportunity.Pipeline_Type__c}" styleClass="companyName"/>
             <b>Impelementation Manager: </b><apex:outputText value="" styleClass="companyName"/>
             <b>Customer Success Manager: </b><apex:outputText value="" styleClass="companyName"/>
             <b>Impelementation Engineer: </b><apex:outputText value="" styleClass="companyName"/>
             <b>Customer Success Associate: </b><apex:outputText value="" styleClass="companyName"/>
             <b>Impelementation Engineer: </b><apex:outputText value="" styleClass="companyName"/>
             <b>Impelementation Engineer: </b><apex:outputText value="" styleClass="companyName"/>
             
            
            
            <apex:outputText value="{!NOW()}"></apex:outputText>
        </apex:panelGrid>
        </center>
    </body>
</apex:page>

Any help would be greatly appreciated!
Best Answer chosen by Tre Pedigo
Raj VakatiRaj Vakati
Remove it from the page layout .. Remove VF page code from the layout 

All Answers

Tre PedigoTre Pedigo
Also, I think its important to mention that if this requires the use of a controller, then I would need to set it up as an extension to the opportunity controller as opposed to a custom controller. This is because I have the vf page nested in the opportunity page layout
Raj VakatiRaj Vakati
I have a simple idea .. it may work for you  .. insted of adding this page to layouts .. create a new button "Donwload MS Doc " and call this page from the button so that it will donwload only when user click on the button 
Tre PedigoTre Pedigo
Raj,
The button was a great idea. Thank you. However, the opportunity page is still automatically downloading the word document. 
Raj VakatiRaj Vakati
Remove it from the page layout .. Remove VF page code from the layout 
This was selected as the best answer
Tre PedigoTre Pedigo
Thank you Raj, sorry for the late response but this did indeed work.