0

The question says it all. I am attempting to insert a tab character into my Word document which is generated with Word interop. The usual \t does not work.

I literally just want to insert some text (tab) text (tab) text; so I am not talking about tab indents at the beginning of a line, but within text itself.

Thanks

user3848640
  • 47
  • 1
  • 5
  • I'm not affiliated in any way, but I've had better luck with the Spire.Doc Nuget package (there's a free version) than I ever had with Word Interop. You might want to look into that, if your question goes unsolved. I'm not sure if it'll do it or not, but I think it should be able to. – Matthew Haugen Jul 18 '14 at 08:46
  • Thanks for this. I'm having a look; looks good so far. – user3848640 Jul 18 '14 at 08:47
  • Yep. I think there are a few things that the free version *doesn't* do, and it's been a little while since I did anything with it, but I know I never encountered a need for any of them, at least with what I was doing. – Matthew Haugen Jul 18 '14 at 08:49

1 Answers1

1

Have you tried this:

wordApp.oWord.ActiveWindow.Selection.TypeText("Your custom text");
WordApp.oWord.ActiveWindow.Selection.TypeText("\t");
wordApp.oWord.ActiveWindow.Selection.TypeText("Your next custom text");
WordApp.oWord.ActiveWindow.Selection.TypeText("\t");

or if you just want to go to the end of the document:

object missing = Missing.Value;
object what = Word.WdGoToItem.wdGoToLine;
object which = Word.WdGoToDirection.wdGoToLast;
doc.GoTo(ref what, ref which, ref missing, ref missing);

credits to Alexander Kojevnikov

Community
  • 1
  • 1
Panayotis
  • 1,743
  • 1
  • 17
  • 30