Code that maximises Word for opening in Vista

Mike375

Registered User.
Local time
Tomorrow, 06:45
Joined
Aug 28, 2008
Messages
2,542
I have been unable to get Access to open Word docs in maximised on Vista. I use the following, which will open the doc maximised in XP, but not Vista

Dim WordObj As Word.Application
Dim WordDoc As Word.Document
Dim WordRange As Word.Range
Set WordObj = CreateObject("Word.Application")
Set WordDoc = WordObj.Documents.Open _
("C:\Letters\0AMPMike.doc")
WordObj.Visible = True

Set WordRange = WordDoc.GoTo(What:=wdGoToBookmark, Name:="a7")

WordDoc.Bookmarks("a7").Select

I have tried adding a line after Set WordObj = CreateObject("Word.Application") which is WordObj.WindowState=wdWindowStateMaximize but that did not work.

The other problem I have relates to the selection of Bookmark (a7). I need the cursor to drop down two lines from the bookmark and I want to avoid using SendKeys as I had some problems with Vista and SendKeys.



 
Office 2003
 
Interesting...this maximizes the current application window:
Code:
Private Const WINSTATE = 3
Private Type POINTAPI
        x As Long
        y As Long
End Type
Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type
Private Type WINDOWPLACEMENT
        Length As Long
        flags As Long
        showCmd As Long
        ptMinPosition As POINTAPI
        ptMaxPosition As POINTAPI
        rcNormalPosition As RECT
End Type
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Dim Rectan As RECT



Private Sub [COLOR="Red"]THIS_ONE_FIRST[/COLOR]()
    'Tip submitted by pyp99 (pyp99@hotmail.com)
    Dim WinEst As WINDOWPLACEMENT
    Dim rtn As Long
    WinEst.Length = Len(WinEst)
    'get the current window placement
    rtn = GetWindowPlacement(Application.hWndAccessApp, WinEst)
    Rectan = WinEst.rcNormalPosition
    RESIZEfunction
End Sub

Private Sub RESIZEfunction()
    Dim WinEst As WINDOWPLACEMENT
    Dim Punto As POINTAPI
    Dim rtn As Long
    'set the new min/max positions
    Punto.x = 100
    Punto.y = 100
    'initialize the structure
    WinEst.Length = Len(WinEst)
    WinEst.showCmd = WINSTATE
    WinEst.ptMinPosition = Punto
    WinEst.ptMaxPosition = Punto
    WinEst.rcNormalPosition = Rectan
    'set the new window placement (max)
    rtn = SetWindowPlacement(Application.hWndAccessApp, WinEst)
End Sub
Is there no easier way!?
 
Is there no easier way!?

Use XP instead of Vista:D

A simple one batch file does it but there are a couple of problems. First, having batch files everywhere. Second, the batch file is no good except to open the Word.doc. Third, if there are linked queries in the doc the MS message comes about...refers to files etc.....

I just fiddled with that code but I am obviously sticking the wriong things in the wrong place:) because I get Not defined function for WinEst As WINDOWPLACEMENT

Can you stick it in a module that I can call. I did play around with a combo of module and some after the code that I current have.
 
post the ENTIRE module that contains the code you posted in the OP. I want everything. And by the way, the the Word.Application method is not compatible in Access 2007! Either that, or it is not in my library yet... :rolleyes:
 
post the ENTIRE module that contains the code you posted in the OP. I want everything. And by the way, the the Word.Application method is not compatible in Access 2007! Either that, or it is not in my library yet... :rolleyes:

I will need to get that sorted out then, not today but soon as I will be getting 2007 so as to have the runtime version.

The code I put in the post to start this thread is exactly what I have. The only difference is that for some of them there are heaps of bookmark entries, followed by copying the document and pasting back to a new record in Access and printing it and closing Word and not saving the changes.
 
Why do you use Word?

The general presentation. Three of them are where Access opens Word, the letter is completed, saved and then Access prints, pastes a copy of the text back to new Access record. It also does our letterhead.

All of the others are pre prepared letters and Access inserts the data into bookmarks etc and then prints.

If I could drop Word and use a Report I would do it in a flash.
 
Why can't you?

For starters, I don't know how to format a sentence or a couple of words in bold type etc. Probably of greater importance is that people who use what I supply "click a label" and Word appears and they can type and highlight etc, close and save and then click the label for "print" then the document is produced etc. with name, address and and so on.

I could do the letterhead OK in a Report for different people, although it would take some time with the formatting, but that would be OK as it would be a "once only".


 
No need to use code.


As you have no doubt discovered, if you maximise your Word doc after it's opened, it doesn't remember this the next time.


But.........



If you "maximise" it by dragging the edges of the Word doc window to the edges of your screen, it should open in that size every time!
 
But you can use simple formatting in say a letter stored in Access for multiple distribution, I don't know how it works down under but If somebody sends me a letter that looks like Joseph's raincoat I throw it straight in the bin;)
 
No need to use code.


As you have no doubt discovered, if you maximise your Word doc after it's opened, it doesn't remember this the next time.


But.........



If you "maximise" it by dragging the edges of the Word doc window to the edges of your screen, it should open in that size every time!

I don't know what to do with what you are saying. There is no Word window that opens, only the button on the botton task bar with the name of the Word.doc. Click on the the task bar button and it displays. The screen is open on Access.
 
But you can use simple formatting in say a letter stored in Access for multiple distribution, I don't know how it works down under but If somebody sends me a letter that looks like Joseph's raincoat I throw it straight in the bin;)

The pre prepared Word docs are discussions on comparing Income Replacement/Disability insurance policy wording and they are not "mail outs". They are delivered after a general presentation. They range from 3 pages to 27 pages and the prospect/client knows he is getting something that is pre prepared. However, these letters are not the problem since they are only printed. For a brief moment the name of the Word.doc appears on the bottom of screen (taskbar), then closes and the printer runs. In fact Vista is better for those than XP. With XP the doc opens then turns black as "select/copy" is done. With Vista, nothing is seen on the screen.

It is the Word docs that are opened for typing that are the problem. The insurance people who have Vista, click all over the place, wondering where the letter is:D

As to a Report, it is simple to have a screen open for a memo field for typing.....but presentation as in making words bold etc is a problem. The other problem is that people are used to typing in Word and the screen appearance that comes with Word.
 
Yes, haven't I read somewhere that 2007 comes with variable formatting, whether or not it works as it says on the box of course is a different matter;)
 

Users who are viewing this thread

Back
Top Bottom