473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

How To Format Data Sent To Word?

I am using "acCmdOutputToRTF" to send the results of a query to Word.
This works well, but the user then has to change the page layout of
the Word document to "landscape" and use the Word "autofit to window"
menu item to make all columns visible because they "run off" the right
hand side of the page.

Is there any way to automate the Word formatting from Access?
Oct 2 '08 #1
2 1665
On Thu, 2 Oct 2008 15:12:17 -0700 (PDT), Wayne
<cq*******@volcanomail.comwrote:

Yes. It's called Automation.
Tip: record a macro in Word to do these things like switch to
Landscape and see what kind of VBA that outputs. This will be the
basis for your code as well.
Tip: the VBA help file only gets installed with a full installation of
Office, not with a typical one.
It all starts with CreateObject("Word.Application"). I'm sure Google
has a ton of links.

-Tom.
Microsoft Access MVP

>I am using "acCmdOutputToRTF" to send the results of a query to Word.
This works well, but the user then has to change the page layout of
the Word document to "landscape" and use the Word "autofit to window"
menu item to make all columns visible because they "run off" the right
hand side of the page.

Is there any way to automate the Word formatting from Access?
Oct 3 '08 #2
On Oct 3, 12:54*pm, Tom van Stiphout <tom7744.no.s...@cox.netwrote:
Yes. It's called Automation.
Tip: record a macro in Word to do these things like switch to
Landscape and see what kind of VBA that outputs. This will be the
basis for your code as well.
Tip: the VBA help file only gets installed with a full installation of
Office, not with a typical one.
It all starts with CreateObject("Word.Application"). I'm sure Google
has a ton of links.

-Tom.
Microsoft Access MVP
Thanks for the heads up Tom. I know that this is rough and that there
will be a million better ways to do this, but the code below is what I
have come up with. It achieves the desired result. The only slight
annoyance is that the first row of the Word table contains the Access
query name, but I can live with that.

On Error Resume Next
DoCmd.Echo False
DoCmd.SetWarnings False
DoCmd.OpenQuery "Query_By_Form_Output"
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
DoCmd.Close acQuery, "Query_By_Form_Output"

Dim oWord As Word.Application
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Documents.Add
oWord.Selection.PageSetup.Orientation = wdOrientLandscape
oWord.Selection.Paste
DoCmd.Echo True
DoCmd.SetWarnings True
Oct 3 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Daniel | last post by:
i would like to konw when the data sent so that i can close the streamwriter and networkstream is there some sort of call backs/events i have to implement for this to work? if so how? can i just...
2
by: Mux | last post by:
I am facing the following problem while exporting data to Word. The current implementation is as described below: I have a JSP file which has a link that enables you to export the data to Word....
3
by: samnagpure | last post by:
Hi, I have a following code to find the format tags in word document and insert some text over there. It works perfectly when I run only a single procedure individually i.e. commenting a call to...
3
by: AA Arens | last post by:
I created at a Word filke containing field and the data is from my database (via ODBC). One of the fields is Date. The format in the database is dd-mm-yyyy (I checked it in VB code), but in the...
2
by: savigliano | last post by:
hello, i am doing a date comparation and i have reallize that the data i have in my database (general date format) it is causing me problems, and because i don´t need the time data i would like to...
1
by: vanand | last post by:
hai, I have wanted to print the data in word document from vb. Now i can able to print the data from database to word without format layout. I need to format the data in word. Kindly send your...
3
by: chandra.krothapalli | last post by:
Hi, I am writing a program to read database logs using db2Readlog/ db2ReadLogNoConn API. I am able to parse the data of "FIXED format data" and link them to appropriate columns for a given...
1
by: arvin09 | last post by:
Please can any one tell me how to tranfer data from word file to asp page
1
by: newbie55 | last post by:
I’m currently using Async sockets with .BeginReceive called to collect any message from clients. I would like to know if the receiving socket received and processed the data sent and throw an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.