[AccessD] [EXTERNAL] Re: Exporting table to a word doc
Rocky Smolin
rockysmolin2 at gmail.com
Fri Aug 18 09:23:28 CDT 2023
Didn’t think of that. The client said word doc but probably would have been
OK with a text file. Each outputted is just the label and the field from a
form.
Anyway, I worked around it with a bit of code, late binding the word
object. And when he wants to add/change order/delete which he surely will,
the code will be quick and easy to maintain.
Tks.
r
On Thu, Aug 17, 2023 at 3:21 PM Shane Groff via AccessD <
accessd at databaseadvisors.com> wrote:
> 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/
> --
> 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