?
Solved

Opening .doc or .docx from Access

Posted on 2014-02-10
6
Medium Priority
?
587 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 52

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 52

Accepted Solution

by:
Rgonzo1971 earned 2000 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 85
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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

770 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