[AccessD] [EXTERNAL] Re: Exporting table to a word doc
Shane Groff
shaneg at microsoft.com
Fri Aug 18 12:11:30 CDT 2023
Ok, I just wanted to confirm that you were seeing the issue I expect.
The error message given, "Cannot Update. Database or object is read-only.", is obviously not correct. The problem is that we only allow the TransferText operation to specific file extensions.
If you did wan to output to Word without using Word automation, you can use DoCmd.OutputTo to export to acFormatRTF, which word can open.
Shane
-----Original Message-----
From: AccessD <accessd-bounces+shaneg=microsoft.com at databaseadvisors.com> On Behalf Of Rocky Smolin
Sent: Friday, August 18, 2023 7:23 AM
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Subject: Re: [AccessD] [EXTERNAL] Re: Exporting table to a word doc
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://data/
> baseadvisors.com%2Fmailman%2Flistinfo%2Faccessd&data=05%7C01%7Cshaneg%
> 40microsoft.com%7C085fa1e437424259a6a408db9ff6baf7%7C72f988bf86f141af9
> 1ab2d7cd011db47%7C1%7C0%7C638279654303839092%7CUnknown%7CTWFpbGZsb3d8e
> yJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C30
> 00%7C%7C%7C&sdata=xaj8Gq6W0tuu94nMHunuLGRUYf31c9nto7ls4P1KxJY%3D&reser
> ved=0
> Website:
> http://www.d/
> atabaseadvisors.com%2F&data=05%7C01%7Cshaneg%40microsoft.com%7C085fa1e
> 437424259a6a408db9ff6baf7%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7
> C638279654303846751%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIj
> oiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=lTJ%2BP
> CHd2Ft%2Bw7XXqvrc2YgRgRRp1LzreIxh%2BKeyGS4%3D&reserved=0
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://data/
> baseadvisors.com%2Fmailman%2Flistinfo%2Faccessd&data=05%7C01%7Cshaneg%
> 40microsoft.com%7C085fa1e437424259a6a408db9ff6baf7%7C72f988bf86f141af9
> 1ab2d7cd011db47%7C1%7C0%7C638279654303851917%7CUnknown%7CTWFpbGZsb3d8e
> yJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C30
> 00%7C%7C%7C&sdata=9J8drEe984AkkE5PrUS6qATZu4PmG0l27ZTiFSb%2BMlQ%3D&res
> erved=0
> Website:
> http://www.d/
> atabaseadvisors.com%2F&data=05%7C01%7Cshaneg%40microsoft.com%7C085fa1e
> 437424259a6a408db9ff6baf7%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7
> C638279654303855988%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIj
> oiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=39HQwNr
> O6o5Xrfgx3FDCYKL%2B068XoqjvGRF%2BZAZO7TI%3D&reserved=0
>
--
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