Solved

Opening .doc or .docx from Access

Posted on 2014-02-10
6
562 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 48

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 48

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now