Ever come across a gem of an answer from ChatGPT that you just need to save for later reference? You’re not alone. ChatGPT often provides responses that are not only insightful but also beautifully formatted, making the information easy to digest and follow.
The challenge, however, arises when you try to preserve not just the content but the formatting as well. You might have noticed the “clipboard” icon and used it to copy the answer, hoping to paste it into Microsoft Word with all its formatting glory intact. Yet, when you paste, you’re met with unformatted markdown text, far from what you expected.
But there’s a workaround that seems promising at first: manually selecting the answer directly from the browser,
copying it, and then pasting it into Word. This method indeed transfers the formatted rich text, but it’s not perfect. You end up with some unsightly borders around lines and paragraphs, detracting from the original aesthetics seen in the browser.
Removing these lines, unfortunately, isn’t straightforward. If you opt to select all and clear all formatting in Word, you’re back to square one, losing much of the very formatting that you aimed to preserve.
Here’s where a bit of VBScript magic comes into play. By running a simple script in Word, you can eliminate those pesky lines, ensuring that the transferred content from ChatGPT retains its formatting, looking almost identical to how it appeared in your web browser.
Sub CleanFormatOfChatGPTPaste()
'This is useful for removing borders when copy/pasting from ChatGPT - 2/10/24 Samir Ghosh.com
Dim para As Paragraph
Dim range As range
'Remove borders for each paragraph
For Each para In ActiveDocument.Paragraphs
Set range = para.range
range.MoveEnd Unit:=wdCharacter, Count:=-1 ' Move end of range to exclude paragraph mark
range.Borders.Enable = False
Next para
'Select entire document and remove any document-wide borders
With ActiveDocument
.Select
Selection.Borders.Enable = False
End With
End Sub
Here’s how to add VB code as a Macro in Microsoft Word in concise steps:
- Open Microsoft Word: Start by opening the document you want to add a macro to or just open Word to create a new document.
- Access the Developer Tab:
- If the Developer tab is not already visible, go to
File
>Options
>Customize Ribbon
. - Check the box next to “Developer” in the right column and click
OK
.
- If the Developer tab is not already visible, go to
- Open the Visual Basic Editor:
- Click on the
Developer
tab on the Ribbon. - Press
Visual Basic
to open the Visual Basic for Applications (VBA) editor.
- Click on the
- Insert a New Module:
- In the VBA editor, right-click on
ThisDocument
of your open document listed in the Project window on the left side. - Select
Insert
>Module
to add a new module for your macro code.
- In the VBA editor, right-click on
- Enter Your VB Code:
- In the newly created module window, type or paste your VB (VBA) script.
- Save Your Macro:
- Press
Ctrl + S
to save your macro. Close the VBA editor and return to your Word document. - Note: If you haven’t saved your document as a macro-enabled document, you’ll need to do so by choosing
File
>Save As
and selecting “Word Macro-Enabled Document (*.docm)” as the file type.
- Press
- Run Your Macro:
- Back in Word, on the
Developer
tab, clickMacros
. - Select your macro from the list and click
Run
.
- Back in Word, on the
These steps will allow you to add and execute VB code as a macro within Microsoft Word, automating tasks and customizing your document processing workflow.
This method ensures that you can keep the insights and formatting from ChatGPT, making your documentation process smoother and your documents more visually appealing. Whether you’re saving snippets for personal reference, academic purposes, or professional documentation, this technique is a game-changer in preserving the integrity of formatted information transferred from digital assistant platforms to Microsoft Word.
Thank you, just what I was looking for!