[AccessD] [EXTERNAL] Re: Exporting table to a word doc

Shane Groff shaneg at microsoft.com
Thu Aug 17 17:21:48 CDT 2023


Hey Rocky, to your original problem, you are writing to a text file, but giving an extension of .docx.
Can you confirm that the command works if you use the .txt extension?

DoCmd.TransferText acExportDelim, , "tblLeaseToWord", "C:\Clients\AGR\Temp\Lease.txt"

Shane

-----Original Message-----
From: AccessD <accessd-bounces+shaneg=microsoft.com at databaseadvisors.com> On Behalf Of Rocky Smolin
Sent: Tuesday, August 15, 2023 12:04 PM
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com>; Off Topic <dba-ot at databaseadvisors.com>
Subject: [EXTERNAL] 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