Solved

Opening .doc or .docx from Access

Posted on 2014-02-10
6
580 Views
Last Modified: 2014-02-10
Hi

We use a small database for tracking all our word documents. The following code opens up the appropriate document in word, but currently opens .doc. I want it to open .doc or .docx, obviously we have both versions now we have upgraded word.

Please help

Private Sub Form_Click()

Dim WDAPP As Object
Set WDAPP = CreateObject("Word.Application")


If Me!Programme = "Word" Then
WDAPP.Documents.Open "y:\windata\" & Forms!frmresults!DocNo & ".doc"
WDAPP.Visible = True
Else
MsgBox ("This is not a Word Document")

End If
DoCmd.Close

End Sub
0
Comment
Question by:SparkyP
6 Comments
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 39847352
Hi,

Is the suffix saved in the DB?

Regards
0
 

Author Comment

by:SparkyP
ID: 39847372
No. The prefix uses the tables ID (incremented), but the suffix is the default when the document is saved in Word.

It has worked fine, but now some machines on our server run on Word 2013 and others 2003.
0
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39847384
i,

I would test it first
wordFile = Dir("y:\windata\" & Forms!frmresults!DocNo & ".doc*")
WDAPP.Documents.Open "y:\windata\" & wordFile

Open in new window

EDIT

if there are 2 files one doc one docx you have to test more

Regards
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 84
ID: 39847444
I want it to open .doc or .docx, obviously we have both versions now we have upgraded word.
I don't quite follow what you mean. You're opening the file as a .doc file here:

WDAPP.Documents.Open "y:\windata\" & Forms!frmresults!DocNo & ".doc"

Does that file already exist on the machine in the "y:\windata" directory? If so, then you can't convert it with the Open command. You'd have to open it in Word and then select to save it as .docx.

That's a Word option (to save in .docx instead of .doc). I suppose you could toggle that when you open the automated instance of Word, but I don't think that's what you're after.
0
 

Author Closing Comment

by:SparkyP
ID: 39847466
Just what I wanted

Many Thanks
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 39847472
i suggest that you should not convert your files to *.docx, because then the users who have word 2003 will not be able to open it.
you should save all files only to *.doc until every one will update to 2013.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question