Copilot for Microsoft 365 Tech Accelerator
Feb 28 2024 07:00 AM - Feb 29 2024 10:30 AM (PST)
Microsoft Tech Community

Unable to open a Word document maximised

Copper Contributor

Hi,

I have tried several suggestions from the web to open a Word document maximised from my Access application.

All are opening the document but not maximising it.

My current code is 

 

Set myWord = CreateObject("Word.Application")
myWord.Visible = True
myWord.Documents.Open FileName:="C:\Users\Norman\Desktop\template for estimates.docx", ReadOnly:=True
With myWord
.Application.WindowState = 1
.ActiveWindow.ActivePane.View.Zoom.Percentage = 100
End With

Set myWord = Nothing
End Sub

 

Anyone any suggestions please?

19 Replies
Maybe the built-in Shell function would work?
Disadvantage is that you would need to know the path to word.exe.
The ShellExecute Windows API does not have this disadvantage.

@Tom_van_Stiphout 

Hi, thanks for the suggestion.

I tried the shell command to open win word and the document and got the same result, not maximised.

@Storming you can use API to Maximize Word window.

@arnel_gp 

 

Can you supply more detail please

@Storming here is a demo, maybe it will work for you.

open basTest Module in VBA and supply the correct word docx.

when done, press F5 to run the 

Thanks, I will try that.
If you don't mind can I ask another question please?
I want to use 2 tables in my letter. The main merge is based on my customer table.
I am trying to list in the letter a table of work items and have tried the following code but it is not working

{DATABASE \d "c:\\Users\\Norman\\Desktop\\Arron.accdb" \s "SELECT [Work job list].Room, [Work job list].Item, [Work job list].Description FROM [Work job list] \h}

Any suggestions please?

@Storming without seeing your db or your docx, i cannot answer you.

btw i use this as mailmerge. the word docx is in Attachment field in Contracts table.

this is but a demo.

@arnel_gp 

Hi, the sql works fine on its own.

Is there anything else i need to do to display the data or should the code i have do it?

@arnel_gp 

Hi, I have attached a cut down version of the database but the main items are there to create the mailmerge.

The WORK table will only ever have 1 row in it (different customer each time) and the WORK JOB LIST table holds the work to be done.

 

Thanks again for your help

@Storming i added WorkID (Foreign Key) on table [Work job list]. this id refers to the WorkID of Work table. instead of Word, i created a report (with subReport), WorkQuote. see the report.

@arnel_gp 

 

Many thanks for your help, it is working great now.

If you don't mind I have 2 last questions:

1) how do i get a footer on the 1st page only

2) where it prints

yours sincerely,

Signature

Typed name

 

Sometimes these 3 lines get split across 2 pages, is it possible to group them so that it would print the 3 lines on the 2nd page if it could not get them all on the 1st page.

@Storming you can play with this demo (WorkQuote3 report). it has some vba on the Open event of the report, so it maintains a constant 15 lines on the detail section. also see the Signature on signatory table.

Hi @arnel_gp 

 

are you sure this is working?

I am getting a variable number of lines on 1st page (up to 24) and nothing on the second page when there are futher work lines to print.

 

Would it be easier if i sent you my current version?

@Storming, please upload your latest db again with data.

Can I send it to you personally?

@Storming , my email: agpuzonATgmail.com.

the AT there is the ampersand symbol, this site remove it for security purpose.

or put it on Onedrive/google drive, etc and email me the link.

Hi, it has removed your email address.

@Storming refresh your screen (F5), i updated my previous post.

Many, many thanks to @arnel_gp.

You have been a star in helping me with this and several other queries.