Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 10th, 2014, 10:48 AM
Friend of Wrox
 
Join Date: Jan 2011
Posts: 103
Thanks: 7
Thanked 0 Times in 0 Posts
Default Access VBA - Run time error 4605

Hi,

I have a access database which I am running in access 2013. I am having the problem where one of the forms has code which opens the Word read only mail merge file, produces the error message "Run-time error '4605': The OpenDataSource method or property is not available because this command is not available for reading".

I have only started having this error message since moving to Access 2013, I have tried making the file non-read only and this stops message appearing. However this is not a helpful solution as I need the file to be read only so it does not get accidental written over. Does any one know of a way to stop this message appearing without having to make the file non-read only. Bleow is the code which opens the mail merge file:

Code:
Dim strFilePath As String
    Dim objWord As Word.Document
    DoCmd.RunMacro "AppRefnew"
    strFilePath = "C:\Letter1.docx"
    Set objWord = GetObject(strFilePath, "Word.Document")
    objWord.Application.Visible = True
    
    objWord.MailMerge.OpenDataSource _
    Name:="C:\database1", _
    LinkToSource:=True, _
    Connection:="TABLE datatable", _
    SQLStatement:="SELECT * FROM [datatable] WHERE [AppRefID]=[Ref2]"
    
    Set objWord = Nothing
Thank you!
 
Old January 11th, 2014, 01:47 AM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

I save my mail merge source documents as a template to prevent them from being over written.
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015





Similar Threads
Thread Thread Starter Forum Replies Last Post
Schedule a VBA macro to run at a specific time marshall04b Excel VBA 8 October 31st, 2015 08:41 AM
Excel 2010 Run Time Error 1004 when trying to Import Access Query flanker22 BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2 0 August 13th, 2012 04:41 PM
Access 2007 Run Time Error 3011 Luckdress Access VBA 2 March 1st, 2012 12:24 PM
Schedule a VBA macro to run at a specific time peterlihh Other Programming Languages 0 October 24th, 2008 07:15 PM
Run-time error 7: Out of Memory - Access 2002 alexisb BOOK: Expert One-on-One Access Application Development 4 October 12th, 2004 12:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.