Solved

Opening .doc or .docx from Access

Posted on 2014-02-10
6
583 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 51

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 51

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

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.

Question has a verified solution.

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

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.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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 start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

690 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