In this post, we’ll cover how to integrate ChatGPT into Microsoft Word. ChatGPT can boost your productivity and significantly enhance your writing capabilities.
For those unfamiliar with ChatGPT, it is a state-of-the-art language model that provides human-like responses. It has gained immense popularity in recent months.
Benefits of Using ChatGPT in MS Word
ChatGPT can be used to enhance your writing and generate content for you in Microsoft Word (see also how it integrates with Excel e PowerPoint). Discover some 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
- Summarize lengthy reports for you
- Provide suggestions for social media posts
- Create templates for emails and proposals
- Assist non-native speakers in translating to other languages
How to Use ChatGPT in Microsoft Word
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 can run on all versions of Office Desktop and Office 365. There are also no prerequisites for using this add-in.
Get OpenAI API Key
First, you need to register by visiting the OpenAI website using this link:
platform.openai.com. By using your existing Google or Microsoft account, you can do this easily. The final step is to obtain
your secret API key to use the OpenAI API. Copy your API key for future reference. The API key looks similar to the text below
sk-xxxxxxxxx
Is the ChatGPT API Free?
The ChatGPT plugin for MS Word is completely free and compatible with all versions of MS Word.
However, please note that the OpenAI API does have applicable charges. These charges are quite affordable. They are determined based on how much you use the API. If you do not use the API at all during a given month, you will not be charged for that period. For more comprehensive pricing details, it is advised to refer to the OpenAI pricing documentation.
Does the 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. API inputs and outputs are kept separate and are not utilized 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 the Add-in
Microsoft blocks external add-in files and states that the origin of this file is not trustworthy. To make the file trustworthy, you need to follow the steps below.
- Navigate to the folder where the add-in downloaded.
- Unzip the file by right-clicking on the zipped file and selecting Extract All.
- Right-click on the file and select Properties from the menu.
- At the bottom of the General tab, check the Unblock checkbox under the Security option, then click OK
To make the add-in available every time you start MS Word, you can save it in the Startup folder. Follow these steps.
- Go to File > Options > Advanced.
- Scroll down to General and click on File Locations.
- Click on Startup > Edit and you will have two options: locate the folder where the downloaded add-in file is stored. OR Instead of modifying the AutoRun folder path, you can also paste the add-in into the existing AutoRun folder.
We recommend using the latter option. If you prefer the first option, make sure to create a new folder and place the downloaded add-in file there, then navigate to the AutoRun folder path in this new folder. This is because if you use a folder, such as the Downloads/Documents folder, that may contain so many word files, MS Word is likely to crash.
How to Use the ChatGPT Add-in
Follow the steps below to use the 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 the tab ChatGPT > AI Writer
- Enter your API key
- The output will be generated and displayed in seconds
- The output will be saved in a new Word document in the same folder where the active Word document is stored
- The output filename is
output_mm-dd-yyyy_hr-min-sec.docx
If your active Word document is not saved anywhere, you will be prompted to select the folder where you want to save the output file.
Resume Generator
You can generate resumes with this add-in. It is important to provide a clear and detailed prompt so that ChatGPT generates a resume tailored to your needs. Always be specific and try multiple prompts to get the best result. See some of the examples below:
Write a professional resume for a [Profile Name]. I have [N] years of experience. My previous titles and companies were [Title, Company Name]. Include bullet points.
Scrivi un curriculum professionale per un Data Scientist. Ho 5 anni di esperienza. I miei titoli e società passati erano Analista, Barclays, Team Lead, JP Morgan. Includi punti elenco.
Write a resume for a [Profile Name] based on this job description. [Add the job description here]
Email Writing
You can ask the ChatGPT add-in to draft an 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-crafted message. You just need to provide the purpose of the email and some context, and ChatGPT will generate a well-written email for you. You can also choose the tone of the email.
Write an email to the manager about taking sick leave tomorrow. My manager’s name is Dave. My name is Deep.
Write an email to the colleague about taking personal leave tomorrow. My colleague’s name is Joe. My name is Deep.The tone should be informal.
It is also good to specify the tone: formal/informal/humorous.
Summary Writing
The ChatGPT add-in can be used to summarize long word documents. For example, you have a long document and you are asked to create a summary based on it. It might be tedious and time-consuming to read the entire text and then write the summary.
Summarize the following text in bullet points – [PASTE TEXT HERE]
How to enable conversation history?
You can improve the output by having ChatGPT remember previous conversation history. The ChatGPT API does not recall previous conversations by default. It treats every API request as a new chat. This means that when it responds to your current question, it doesn’t remember your previous query.
To enhance the ChatGPT experience, we have a feature called ”
Chat” in the plugin. Watch the demo video below. In this example, we asked ChatGPT to create a resume by providing some details about the job and past work experience. The resume was generated accordingly. To improve the resume, we asked ChatGPT to add internship experience. If you notice, it remembered the previous instructions and only included the internship experience while keeping the rest of the resume the same.
The
Resetbutton starts a new chat and removes the previous conversation history. Use this button when you do not need the chat history to generate output.
How to define the style of ChatGPT output?
You can style the MS Word document by adding the following lines to the end of the prompt you ask ChatGPT
- Highlight the headings in dark blue color.
Scrivi un curriculum per un ingegnere del software. Evidenzia i titoli in colore blu scuro.
- Include bullet points.
- Please format the text in italics.
- The text should be in red color.
In the next paragraph, we will go through 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 the VBA code serve the same purpose.
The advantage of using the add-in is that it opens automatically whenever you open a new Word document. Whereas the MS Word Macro file is specific to a particular Word document. You need to open the same macro file every time to access ChatGPT. The add-in also performs formatting in the Word document.
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 the 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-xxxxxxxxxxxxxxxxxxxxxxx"
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
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 the VBA code
The following steps provide basic instructions for using the VBA code in MS Word.
- Press Alt+F11 to open the VBA editor.
- Click on Insert > Module to create a new module.
- In the module, paste the VBA code.
- Replace the API key
api_keywith your actual API key. - Close the VBA editor.
- Run the macro by pressing Alt+F8, then select ChatGPT and press the RUN button.
If you want to use ChatGPT-4 , you can replace
gpt-3.5-turbowithgpt-4the VBA code above.
How to optimize ChatGPT output
In the additional/VBA code above, you’ll find a temperature parameter. It ranges from 0 to 2. Increasing the value, for example 1.2, will result in more random output, while decreasing the value, like 0.2, will result in more focused output.
Steps for troubleshooting errors
Error: You have exceeded your current quota, please check your plan and billing details : to fix this, you’ll need to upgrade to a paid account that charges you based on API usage. This is not ChatGPT Plus but a paid plan for API usage. It’s very affordable, costing you approximately less than a dollar a month even when you use the API extensively every day.
Visit the OpenAI website. Log in, go to the Billing page, and sign up for the “Pay as you go” plan using 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’s also possible that your limit has been set too low. You can check your current quota in your account settings.
The error The model: gpt-4 does not existmeans you don’t have access to the GPT-4 API. To get access you need to sign up for the waitlist. Your subscription to ChatGPT Plus (the paid version of ChatGPT) does not guarantee access to the GPT-4 API automatically, regardless of whether you have it or not.
If you mistakenly chose GPT-4 instead of GPT-3.5 or entered the wrong API key, you can correct this by clicking the Update Keybutton to specify the correct model type and API key. Once you’re done, you can verify it by clicking the Check Keybutton.
Sometimes, the ChatGPT API behaves strangely and starts producing errors. If the add-in was working correctly before but is now returning errors, I suggest trying a few more times. If the problem persists, please report it.
Source listendata
Pubblicato in Word & PowerPoint
Be the first to comment