How can I use UiPath with C# Invoke Code to open a Word document and insert "Hello World" with center alignment?

You may need to remove those Using statements and import the namespaces in the project itself if not yet done.

Also check if your project is set to VB or C# looking at the ‘line 5 error’.
The similair solution also works in VB, you just need to use VB syntax. The used interop methods remain the same.