Insert code ( sql, php )into word doc

scud

Senior Member
Joined
Sep 1, 2005
Messages
766
#1
Don’t know why but I never get this right.
What’s the best way to add code snippets to a word doc.

I’ve tried insert object , but it only lists a few ms options .

Also need to share the doc with others , so don’t really want to use a plugin

Any ideas would be appreciated
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
5,648
#3
There is no really simple solution, hence most people I know choose to use Markdown editors instead of word. A good markdown editor is Typora

If you have to stick with word, then the best way I've found is":
Menu Insert,object, Microsoft Word Document
Then remove margins, and drag and drop highlighted code from your IDE into that word document; fix the styling, fonts, size, ... save and close.
Then resize that Inserted Objected as you need.

Example:
 

Attachments

scud

Senior Member
Joined
Sep 1, 2005
Messages
766
#4
There is no really simple solution, hence most people I know choose to use Markdown editors instead of word. A good markdown editor is Typora

If you have to stick with word, then the best way I've found is":
Menu Insert,object, Microsoft Word Document
Then remove margins, and drag and drop highlighted code from your IDE into that word document; fix the styling, fonts, size, ... save and close.
Then resize that Inserted Objected as you need.

Example:
Thanks droid - perfect
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
5,648
#7
Using the easy way, using snipping tool, mark the code you want, copy and paste as a picture
Not such an easy way if it's a lot of code that has the potential to change + background, theme and screen grab size affects the outcome. For this markdown is still the simplest and most flexible option, hence many code book authors out for it.
 

freddster

Expert Member
Joined
Dec 13, 2013
Messages
2,471
#8
Not such an easy way if it's a lot of code that has the potential to change + background, theme and screen grab size affects the outcome. For this markdown is still the simplest and most flexible option, hence many code book authors out for it.
I was thinking just a code snippet. If lots are used reguarly then obviously. So changing the code and update the doc would be much easier. Can think how tedious this can get using snipping tool.
 

scud

Senior Member
Joined
Sep 1, 2005
Messages
766
#9
My issue is when dealing with one client, they want me do give them a word doc, like a manual, but with code to show editable sql queries they can use for powerbi etc
Not the way I normally do things , but after all of these years I would have thought word would have been able to easily do this
 

Johnatan56

Honorary Master
Joined
Aug 23, 2013
Messages
20,755
#10
Not such an easy way if it's a lot of code that has the potential to change + background, theme and screen grab size affects the outcome. For this markdown is still the simplest and most flexible option, hence many code book authors out for it.
I think IntelliJ copies with formatting, so can download communuty edition and try pasting with that? Only done it in PowerPoint though.

Droids solution is the first hit on Google btw.

https://www.lifewire.com/insert-source-code-into-word-document-3994582
 

Nod

Executive Member
Joined
Jul 22, 2005
Messages
8,563
#11
I normally placed code in a text frame with a "Source Code ..." type font, or a console type font.
 
Top