I haven't used them but there are VS extensions that will let you copy code with line numbers and copy as HTML with syntax highlighting. Not sure if there's a single extension that will let you do both at the same time.

https://marketplace.visualstudio.com...rtBy=Relevance

Actually, the line number extension I saw may have been for VS Code.