1

in my application I use

using Word = Microsoft.Office.Interop.Word;

and now I need to change my table column width to 3 cm and as I understand standard methods use points not cm or inches, so I wanna to convert it to points. As I read in MSDN there must be function InchesToPoints (http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word._application.inchestopoints(v=office.14).aspx)

But when I use this code

wordtable.Columns[0].Width = Application.InchesToPoints(3f / 2.54f);

there is an exception:

Error 1 'System.Windows.Forms.Application' does not contain a definition for 'InchesToPoints' Z:\porn\WindowsFormsApplication3\Form1.cs 194 62 WindowsFormsApplication3

What should I do???

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
pad0n
  • 187
  • 3
  • 17

1 Answers1

1

Application refers to the hosting application in VBA.

From outside you need to use word.InchesToPoints (where word is the Word instance variable).

GSerg
  • 76,472
  • 17
  • 159
  • 346
  • Yeap, but I couldn't create instance variable, coz ` 'Microsoft.Office.Interop.Word' is a 'namespace' but is used like a 'type' ` this one returned me after this code: ` Word word = new Word(); ` – pad0n Sep 13 '13 at 08:52
  • You seem to be using [namespace aliasing](http://stackoverflow.com/q/2325097/11683) without understanding what it is. Don't use it then. `var word = new Microsoft.Office.Interop.Word.Application();`. – GSerg Sep 13 '13 at 09:01