Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I size Word from within a VB program?

Status
Not open for further replies.

MarcMellor

Programmer
Jan 12, 2002
34
US
I want to be able to open word from my VB program I am working on to be able to use it as a text editor. I can get it maximised - MSWord.WindowState = wdWindowStateMaximise or minimised, but nothing in between ( with wdWindowStateNormal it seems to be minimised). I need to be able to set its Top, Left, Height and Width properties so that other controls can be seen by the user at run time but with MSWord.Top = 1000 etc it either remains minimised or returns an error saying it is maximised.
Any ideas?
 
tried this on my machine and it works
I think the problem you may be having is that the values you are using are too large
the .Top, .Left, .Width, and .Height properties of the word application object are all in points not in pixels or twips


Code:
Dim WithEvents moWord As Word.Application

Private Sub Command1_Click()
  Set moWord = New Word.Application
  With moWord
    .WindowState = wdWindowStateNormal
    .Top = 50
    .Left = 50
    .Width = 500
    .Height = 500
    .Visible = True
    MsgBox "pause"
    .Quit wdDoNotSaveChanges
  End With
  Set moWord = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top