Solved

Opening .doc or .docx from Access

Posted on 2014-02-10
6
570 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 49

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 49

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 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