ChatGPT for Microsoft Word: A Step-by-Step Guide

In this post we will cover how to integrate ChatGPT into Microsoft Word. ChatGPT can boost your productivity and significantly improve your writing capabilities. Those who don't know ChatGPT, it is a state of the art language model which provides human like responses. It has gained huge popularity in recent months.

Integrate ChatGPT into Word
Table of Contents

Method 1: MS Word Plugin for ChatGPT

Integrating ChatGPT into MS Word has never been easier with the ChatGPT plugin (add-in). You can download the add-in using the link below. It is absolutely free and and can run on all the versions of Office Desktop and Office 365. Also there are no prerequisites for using this add-in.

Demo Video
Get OpenAI API Key

First you need to sign up by visiting OpenAI website using this link - platform.openai.com. By using your existing Google or Microsoft account you can do it easily. Last step is to get secret API key to use OpenAI API. Copy your API key for future reference. API Key looks like the text below

sk-xxxxxxxxx

Is ChatGPT API Free?

The ChatGPT Plugin for MS Word is completely free to use and compatible with all versions of MS Word. However, please note that the OpenAI API comes with applicable charges. These charges are quite affordable. They are determined based on how much you use the API. If you don't use the API at all during a particular month, you won't be billed for that period. For more comprehensive pricing details, it is recommended to refer to OpenAI's pricing documentation.

Does ChatGPT API Use My Data?

OpenAI's data privacy policy states that user data submitted through their API is not used to train their models. The inputs and outputs of the API are kept separate and are not used in the training process of their models. This commitment to data privacy ensures that user information remains secure and confidential while using the API.

Steps to install add-in

Microsoft blocks external add-in files and says the source of this file is untrusted. To make the file trusted, you need to follow the steps below.

  1. Go to the folder where the downloaded add-in file is located.
  2. Unzip the file by right click the zipped file and select Extract All.
  3. Right-click the file and choose Properties from the menu.
  4. At the bottom of the General Tab, select the Unblock checkbox under security option and then click Ok

To make the add-in to be available each time you launch MS Word, you can save it in the Startup folder. Follow the steps below.

  • Go to File > Options > Advanced.
  • Scroll down to General and click on File Locations.
  • Click on Startup > Modify and then you have two options - Either you locate the folder where downloaded add-in file is stored. OR Instead of changing the Startup folder location, you can also paste the add-in in the existing Startup folder.
    It is recommended to use the latter option. If you prefer first option, make sure to create a new folder and put the downloaded add-in file there and then navigate the location of Startup folder to this new folder. It is because if you use a folder for e.g. Download/Documents folder which may contain so many word files, it is likely MS Word would crash.

How to use ChatGPT add-in

Follow the steps below to use ChatGPT add-in for MS Word.

  1. Open a new or existing MS Word document
  2. Type the text you want to ask ChatGPT
  3. Select the text you typed in the previous step
  4. Click on ChatGPT Tab > AI Writer
  5. Enter your API Key
  6. Output will be generated and appeared in a few seconds
  7. Output will be saved in a new word document in the same folder where your active word document is stored
  8. File name of output file is output_mm-dd-yyyy_hr-min-sec.docx
If your active Word document is not saved in any location, it will prompt you to select the folder where you want to save the output file.
Resume Builder

You can generate resume with this add-in. It is important that you provide a clear and detailed prompt so that ChatGPT generates resume according to your requirements. Always be specific and try with multiple prompts for best outcome. See some of the examples below -

Write a professional resume for a [Profile Name]. I have [N] years of experience. My past titles and companies were [Title, Company Name]. Include bullet points.
Write a professional resume for a Data Scientist. I have 5 years of experience. My past titles and companies were Analyst, Barclays, Team Lead, JP Morgan. Include bullet points.
Write a resume for a [Profile Name] based on this job description. [Add Job Description Here]
Email Writing

You can ask ChatGPT Add-in to draft email for you. Whether you need to send a formal business email or a friendly message to a colleague or friend, ChatGPT can help you write a professional and well-drafted message. You just need to provide the purpose of email and some context and ChatGPT will generate a well-written email for you. You can also choose the tone of email.

Write an email to manager about sick leave tomorrow. My Manager’s name is Dave. My name is Deep.
Write an email to colleague about personal leave tomorrow. My colleague’s name is Joe. My name is Deep. Tone should be informal.

It's also good to specify tone - formal / informal/ humorous.

Summary Writing

ChatGPT Add-in can be used to summarize lengthy word document for you. For example you have a long document and you are asked to create summary based on it. It may be time consuming and boring to read the whole text and then write summary.

Summarise the text below in bullet points - [PASTE TEXT HERE]

How to Improve ChatGPT Generated MS Word Document?

You can improve output by making ChatGPT remember previous conversation history. ChatGPT API does not recall previous conversations by default. It treats each API request as a new chat. This means that when it answers your current question, it does not remember your previous question.

To enhance ChatGPT experience we have a feature called "Chat" in the plug-in. See the demo video below. In this example, we asked ChatGPT to make a resume by giving it some details about the job and previous work experience. The resume was generated accordingly. To make the CV better, we asked ChatGPT to add internship experience. If you notice, it remembered the previous instructions and included only the internship experience while keeping the rest of the resume the same.

The Reset button starts a new Chat and removes prior conversation history. Use this button when you don't need chat history to generate output.

How to style ChatGPT Output?

You can style MS Word Document by adding the following lines to the end of the prompt you ask ChatGPT

  • Highlight the headings in dark blue color.
    Write a resume for a Software Engineer. Highlight the headings in dark blue color.
  • Include bullet points.
  • Please format the text to be italic.
  • Text should be in red colour.

Note : In the next section we will see the source code of this add-in. If you are not interested in knowing the source code, you can skip the next section. The add-in and VBA code serve the same purpose.

The benefit of using add-in is that it opens automatically every time you open a new word document. Whereas MS Word Macro file is specific to a particular word document. You have to open the same macro file each time to access ChatGPT. Also the add-in performs formatting in the word document.

Method 2: VBA Code to Integrate ChatGPT with MS Word

You can use the VBA Code below to run ChatGPT in MS Word. Make sure to change API Key (highlighted in bold below).

Sub chatGPT()

    Dim request As Object
    Dim text As String, response As String, API As String, api_key As String, DisplayText As String, error_result As String
    Dim startPos As Long, status_code As Long
    Dim prompt As String
    Dim selectedText As Range

    'API Info
    API = "https://api.openai.com/v1/chat/completions"
    
    'API Key
    api_key = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxx"

    If api_key = "" Then
        MsgBox "Error: API key is blank!"
        Exit Sub
    End If
    
    ' Prompt the user to select text in the document
    If Selection.Type <> wdSelectionIP Then
        prompt = Trim(Selection.text)
        Set selectedText = Selection.Range
    Else
        MsgBox "Please select some text before running this macro."
        Exit Sub
    End If
        
    'Cleaning
    text = Replace(prompt, Chr(34), Chr(39))
    text = Replace(text, vbLf, "")
    text = Replace(text, vbCr, "")
    text = Replace(text, vbCrLf, "")

    ' Remove selection
    Selection.Collapse

    'Create an HTTP request object
    Set request = CreateObject("MSXML2.XMLHTTP")
    With request
        .Open "POST", API, False
        .setRequestHeader "Content-Type", "application/json"
        .setRequestHeader "Authorization", "Bearer " & api_key
        .send "{""model"": ""gpt-3.5-turbo"",  ""messages"": [{""content"":""" & text & """,""role"":""user""}]," _
             & """temperature"": 1}"
      status_code = .Status
      response = .responseText
    End With

    'Extract content
    If status_code = 200 Then
      DisplayText = ExtractContent(response)
                
    'Insert response text into Word document
    selectedText.InsertAfter vbNewLine & DisplayText

        
    Else
        startPos = InStr(response, """message"": """) + Len("""message"": """)
        endPos = InStr(startPos, response, """")
        If startPos > Len("""message"": """) And endPos > startPos Then
            DisplayText = Mid(response, startPos, endPos - startPos)
        Else
            DisplayText = ""
        End If
        
        'Insert error message into Word document
        EDisplayText = "Error : " & DisplayText
        selectedText.InsertAfter vbNewLine & EDisplayText
        
    End If
    
    
    'Clean up the object
    Set request = Nothing

End Sub


Function ExtractContent(jsonString As String) As String
    Dim startPos As Long
    Dim endPos As Long
    Dim Content As String
    
    startPos = InStr(jsonString, """content"": """) + Len("""content"": """)
    endPos = InStr(startPos, jsonString, "},") - 2
    Content = Mid(jsonString, startPos, endPos - startPos)
    Content = Trim(Replace(Content, "\""", Chr(34)))
        
    Content = Replace(Content, vbCrLf, "")
    Content = Replace(Content, vbLf, "")
    Content = Replace(Content, vbCr, "")
    Content = Replace(Content, "\n", vbCrLf)
     
    If Right(Content, 1) = """" Then
      Content = Left(Content, Len(Content) - 1)
    End If
    
    ExtractContent = Content

End Function
How to use VBA code

The following steps provide basic instructions for using VBA code in MS Word.

  1. Press Alt+F11 to open the VBA editor.
  2. Click Insert > Module to create a new module.
  3. In the module, paste the VBA code.
  4. Replace API Key in api_key with your actual API key.
  5. Close the VBA editor.
  6. Run the macro by pressing Alt+F8 and then select ChatGPT and hit RUN button.
If you want to use ChatGPT-4, you can replace gpt-3.5-turbo with gpt-4 in the above VBA code.

How to fine tune ChatGPT Output

In the above add-in/VBA code, you will come across a temperature parameter. It ranges from 0 to 2. Increasing the value, such as 1.2, will result in a more random output, whereas decreasing the value, like 0.2, will return a more focused output.

Steps for troubleshooting errors

1. Error: You exceeded your current quota, please check your plan and billing details
Solution : To fix this issue, you will need to upgrade to a paid account that charges you based on your API usage. This is not ChatGPT Plus but a paid plan for using API. It's very affordable, would roughly cost you less than a dollar per month even when you use API extensively daily.

  1. Visit OpenAI's website.
  2. After logged in, go to Billing page, and sign up for "Pay as you go" plan with your debit or credit card. If you are already using this plan, this error indicates that you are sending a high volume of requests to ChatGPT, which it cannot handle. It is also possible that your limit has been set too low. You can check your current quota in your account settings.

2. The error The model: gpt-4 does not exist means you don't have access to GPT-4 API. You must join the waitlist to access it. Your subscription to ChatGPT Plus (paid version of ChatGPT) does not guarantee automatic access to the GPT-4 API, regardless of whether you have it or not.

3. If you either mistakenly choose GPT-4 instead of GPT-3.5 or entered incorrect API Key, you can correct it by clicking the Update Key button to specify the correct Model Type and API Key. Once done, you can check it by clicking on the Check Key button.

4. Sometimes, the ChatGPT API acts strangely and starts producing errors. If the add-in was working fine for you before but is now returning errors, I suggest trying again a few more times. If the issue persists, please report it.

Refer the detailed guide about how to run ChatGPT in MS Excel and PowerPoint
ChatGPT Plugin for MS Excel
ChatGPT Plugin for MS PowerPoint.
Related Posts
Spread the Word!
Share
About Author:
Deepanshu Bhalla

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and HR.

0 Response to "ChatGPT for Microsoft Word: A Step-by-Step Guide"

Post a Comment

Next → ← Prev
Ad-Blocker Detected