Word and access 2013

Hi EE

Still having trouble opening word in access 2013. I have the following

Dim db As DAO.Database, rs As DAO.Recordset
    Dim search
    Set db = CurrentDb
    search = "SELECT * FROM tblConfig WHERE [ConfigID] = " & 1
    Set rs = db.OpenRecordset(search)
    DocLocation = rs.Fields("DocumentLocation")
    OrgID = Me!txtOrgID
    Organisation = Me!txtOrgname
    DocFileName = "HO" & OrgID & Organisation & ".docx"
    If Right(DocLocation, 1) = "\" Then
        path = DocLocation & DocFileName
    Else
        path = DocLocation & "\" & DocFileName
    End If

   Dim wrdApp As Word.Application
   Dim wrdDoc As Word.Document
   
    If Dir(path) <> "" Then
           Set wrdApp = CreateObject("Word.Application")
           wrdApp.Visible = True
           wrdApp.Activate
           Set wrdDoc = wrdApp.Documents.Open(path)
           wrdDoc.Application.WindowState = wdWindowStateMaximize
           wrdDoc.Activate
    Else
            MsgBox ("There is no Document for this project"), vbOKOnly, "Message"
   
    End If

At the moment wdWindowsState is maximised, I have tried Normal When I run word opens in the background (Underneath the opening form)
Before I introduced the line wdWindowsState word would open minimised. I just want word to allways open over the access form. I have made form Popup and model = no. If I transfer the code and run access 2003 there is no problems. Any help appreciated

chestera
chesteraAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
>>I just want word to allways open over the access form.
Not too sure and this is just a quick guess... what if you try use ShellExecute API to launch the word document? like:

Add this at the top of your module:
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Function StartDoc(ByVal FileName As String, Optional CommandLine As String = "") As Long
    StartDoc = ShellExecute(0&, "Open", FileName, CommandLine, vbNullString, 1)
End Function

Open in new window

and then call it like:

 If Dir(path) <> "" Then
          StartDoc path
    Else
            MsgBox ("There is no Document for this project"), vbOKOnly, "Message"    
    End If

See if this works for you?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chesteraAuthor Commented:
Ryan Chong

Thank you Ryan I will give it a try and get back to you. I will be away from PC for a while

Alan
chesteraAuthor Commented:
Ryan Chong

Sorry for the delay I have been away. Tried your Shell routine this morning and it worked. Many thanks.
I hope you don't mind before I close off I have a minor problem unrelated to word. I have asked the question before some months ago and couldn't get an answer.

I work from home and I have Office 2013 installed on one of my PC''s. The office uses Microsoft 365 (office2013). Problem if I generate an accde from home and run on the office PC I get the message this program was developed in a later version of Access. I then have to recompile (accde) on a PC in the office to get it to run, It's no big deal but I would like to know why. Have you any ideas, My office is the professional version. I would have assumed Microsoft 365 would be more current than my copy is a couple of years old

Alan
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
@Alan,

Glad that it solves your problem cheers!

for your another question... actually I'm not using Microsoft 365 as well as accde file before, so I may not in a good position to answer you this. However... perhaps you can run the following script to test what's the "version" returned from both your home and office's machines, see if the home one is actually higher than the your office one.
debug.print application.Version & " " & application.Build & " " & application.ProductCode

Open in new window

Hope this gives you some clues that you want.
chesteraAuthor Commented:
Ryan Chong

Thank you Ryan for all your help and that script

Alan
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.