Jump to content

Paste from SSMS or Visual Studio into OneNote with formatting

Recommended Posts

When I copy code from Visual Studio or SQL Server Management Studio (SSMS) and paste it into OneNote, it loses all formatting.

Here's how it originally looks in SSMS:



Here's how it looks when pasted into OneNote no matter which Paste Option I select:



My workaround is to copy from SSMS and paste into a blank Word document, then copy from Word and paste into OneNote.

I'd like to use AutoIt override ctrl-v in OneNote to paste with the formatting, but I can't figure out how.

I've looked through the documentation for ClipGet, ClipSet, _ClipBoard_SetData, and _ClipBoard_GetData

Here's the code I've tried so far.  I copy the text from SSMS, run the script, press ctrl-v in OneOne, but nothing pastes.  Any idea what i'm doing wrong?

#include <Clipboard.au3>

Func _Example()

    Local $iClipboardFormat = _ClipBoard_RegisterFormat("Rich Text Format")
    Local $vClip = _ClipBoard_GetData($iClipboardFormat)
    _ClipBoard_SetData($vClip, $iClipboardFormat)


The clipboard program Ditto shows that the clipboard has 3 formats: CF_TEXT, CF_UNICODETEXT, and Rich Text Format

This script on the _ClipBoard_EnumFormats page shows the Clipboard has 7 formats and I've tried them all in the code above:

Clipboard formats ..: 7
Clipboard format 1 .: DataObject
Clipboard format 2 .: Unicode Text
Clipboard format 3 .: Rich Text Format
Clipboard format 4 .: Ole Private Data
Clipboard format 5 .: Locale
Clipboard format 6 .: Text
Clipboard format 7 .: OEM Text



Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...