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.

Benefits of using ChatGPT in MS Word
ChatGPT can be used to improve your writing and generate content for you in Microsoft Word. See some of the ways you can use it in Word -
- Generate a tailored resume for the job based on the job description
- Generate content for blog posts or articles
- Summarise lengthy reports for you
- Provide suggestions for social media posts
- Create templates for emails and proposals
- Help non-native speakers in translating in other languages
How to Use ChatGPT in Microsoft Word
Integrating ChatGPT into MS Word has never been easier with the ChatGPT 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.
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
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.
- Go to the folder where the downloaded add-in file is located.
- Right-click the file and choose Properties from the menu.
- 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.
- Open a new or existing MS Word document
- Type the text you want to ask ChatGPT
- Select the text you typed in the previous step
- Click on ChatGPT Tab > AI Writer
- Enter your API Key
- Output will be generated and appeared in a few seconds
- Output will be saved in a new word document in the same folder where your active word document is stored
- File name of output file is
output_mm-dd-yyyy_hr-min-sec.docx
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]
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.
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 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.
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.
VBA Code to run ChatGPT in MS Word
You can use the VBA Code below to run ChatGPT inside MS Word. Make sure to change API Key (highlighted in yellow 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-xxxxxxxxxxxx"
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, ""top_p"": 0.7}"
status_code = .Status
response = .responseText
End With
'Extract content
If status_code = 200 Then
Result = Split(response, """,""")
For i = LBound(Result) To UBound(Result)
If InStr(Result(i), "content") > 0 Then
startPos = i
Exit For
End If
Next i
DisplayText = Mid(Result(startPos), InStr(Result(startPos), ":") + 2, InStr(Result(startPos), """},"))
DisplayText = Mid(DisplayText, 1, InStr(DisplayText, """},") - 1)
DisplayText = Replace(DisplayText, "\""", Chr(34))
DisplayText = Replace(DisplayText, "\n", vbLf)
'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
The following steps provide basic instructions for using VBA code in MS Word.
- Press Alt+F11 to open the VBA editor.
- Click Insert > Module to create a new module.
- In the module, paste the VBA code.
- Replace API Key in
api_key
with your actual API key. - Close the VBA editor.
- Run the macro by pressing Alt+F8 and then select ChatGPT and hit RUN button.
If you want to use ChatGPT-4, you can replacegpt-3.5-turbo
withgpt-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 yield a more focused output.
ChatGPT Plugin for MS Excel
ChatGPT Plugin for MS PowerPoint.
Post a Comment