[AccessD] Exporting table to a word doc

Daniel Waters df.waters at outlook.com
Tue Aug 15 14:43:12 CDT 2023


Hi Rocky,

You might try this:

Dim fileName as string
fileName = "C:\Clients\AGR\Temp\Lease.docx"
....
....

'-- Then,
 wordApp.SaveAs filename 

Dan

-----Original Message-----
From: AccessD <accessd-bounces+df.waters=outlook.com at databaseadvisors.com> On Behalf Of Rocky Smolin
Sent: 15 August, 2023 14:04
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com>; Off Topic <dba-ot at databaseadvisors.com>
Subject: Re: [AccessD] Exporting table to a word doc

OK - I switched to VBA code - late binding. Got the word doc created and added the text.  Just need the syntax to save it.

    Dim wordApp As Object
    Dim myDoc As Object
    Set wordApp = CreateObject("Word.Application")
    Set myDoc = wordApp.Documents.Add()

*** Create the text in the doc and then...

   wordApp.SaveAs fileName:="C:\Clients\AGR\Temp\Lease.docx"

throws the error: object doesn't support this property or method.

Does anyone know the correct syntax to save this doc?

MTIA

Rocky




On Tue, Aug 15, 2023 at 10:09 AM Rocky Smolin <rockysmolin2 at gmail.com>
wrote:

> Dear List(s):
>
> I have a very simple requirement to export a table with records of one 
> field - field is text format. I use:
>
>     DoCmd.TransferText acExportDelim, , "tblLeaseToWord", 
> "C:\Clients\AGR\Temp\Lease.docx"
>
> I get the error message "Cannot Update. Database or object is read-only."
>
> I tried it with the doc file \Lease.docx already created, empty and 
> without the doc file present. ICn  assume if I can get this to work 
> the doc file will be created by the export? Doesn't need to pre-exist 
> the TransferText?
>
> What's the fix for this? Or  is there a better way to export the 
> records in this table?
>
> MTIA,
>
> Rocky
>
>
>
--
AccessD mailing list
AccessD at databaseadvisors.com
https://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list