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