Jump to content
Sign in to follow this  
DanielEms

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:

ssms_code.png.21f7111afad8ac9ab04a1af1c7b08373.png

 

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

pasted_from_ssms.png.a1a0c0b19db337e70dd9a294293453d4.png

 

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>

_Example()
Func _Example()

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

EndFunc

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
 

ssms_code.png

pasted_from_ssms.png

Share this post


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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...