This is a multi-part message in MIME format.
------=_NextPart_000_0006_01C83365.540730D0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I have a macro in Word that I want to move to my MSAccess app and run =
from MSAccess. It merges a form file with a data file to a new screen, =
then prints and exits:
Application.ScreenUpdating =3D False
=20
Documents.Open FileName:=3D"K:\legalper\mergform.doc", =
ConfirmConversions:=3D _
False, ReadOnly:=3DFalse, AddToRecentFiles:=3DFalse, =
PasswordDocument:=3D"", _
PasswordTemplate:=3D"", Revert:=3DFalse, =
WritePasswordDocument:=3D"", _
WritePasswordTemplate:=3D"", Format:=3DwdOpenFormatAuto
With ActiveDocument.MailMerge
.Destination =3D wdSendToNewDocument
.Execute
End With
' PRINT AND EXIT
Application.PrintOut FileName:=3D"", =
Range:=3DwdPrintAllDocument, Item:=3D _
wdPrintDocumentContent, Copies:=3D1, Pages:=3D"", =
PageType:=3DwdPrintAllPages, _
ManualDuplexPrint:=3DFalse, Collate:=3DTrue, =
Background:=3DFalse, PrintToFile:=3D _
False, PrintZoomColumn:=3D0, PrintZoomRow:=3D0, =
PrintZoomPaperWidth:=3D0, _
PrintZoomPaperHeight:=3D0
ActiveDocument.Close SaveChanges:=3DwdDoNotSaveChanges
Application.Quit SaveChanges:=3DwdDoNotSaveChanges =20
Thanks to RM, I have successfully revised as follows, but it's jamming =
with my Application.PrintOut options in bold below:
Public Function Env()
Dim wd As Object
Dim wdActiveDoc As Object 'RM: Added this to help ensure that you're
'working on the document you intend to.
Dim wdField As Object 'RM: Note the change in name here to avoid
'ambiguity with the Field object in both Word =
and
'Access. As well, I changed the type, since
'(like Word.Application), you have to use late
'binding.
=20
Set wd =3D CreateObject("Word.Application")
wd.Visible =3D True
wd.Application.ScreenUpdating =3D False
=20
Set wdActiveDoc =3D wd.Documents.Open("K:\legalper\mergform.doc", =
False, False, _
False, "", "", False, "", "", 0)
=20
With wdActiveDoc.MailMerge
.Destination =3D 0
.Execute
End With
wd.Windows("mergform.doc").Activate
wd.ActiveWindow.Close 0
' PRINT AND EXIT: PLEASE HELP ME HERE:
wd.Application.PrintOut =3D "", 0, 0, 1, "", 0, False, True, =
False, _
False, 0, 0, 0, 0
------=_NextPart_000_0006_01C83365.540730D0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16544" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2><STRONG>I have a macro in Word that I =
want to move=20
to my MSAccess app and run from MSAccess. It merges a form file with a =
data file=20
to a new screen, then prints and exits:</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial=20
size=3D2>Application.ScreenUpdating =3D False</FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><?xml:namespace =
prefix =3D o ns=20
=3D "urn:schemas-microsoft-com:office:office" /><o:p><FONT =
face=3DArial=20
size=3D2> </FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN style=3D"mso-spacerun: yes"> =20
</SPAN>Documents.Open FileName:=3D"K:\legalper\mergform.doc",=20
ConfirmConversions:=3D _</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes"> =20
</SPAN>False, ReadOnly:=3DFalse, AddToRecentFiles:=3DFalse,=20
PasswordDocument:=3D"", _</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes"> =20
</SPAN>PasswordTemplate:=3D"", Revert:=3DFalse, =
WritePasswordDocument:=3D"",=20
_</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes"> =20
</SPAN>WritePasswordTemplate:=3D"", =
Format:=3DwdOpenFormatAuto</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN style=3D"mso-spacerun: yes"> =
</SPAN>With=20
ActiveDocument.MailMerge</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN style=3D"mso-spacerun: =
yes"> =20
</SPAN>.Destination =3D wdSendToNewDocument</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes"> =20
</SPAN>.Execute</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN style=3D"mso-spacerun: yes"> =
</SPAN>End=20
With</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial=20
size=3D2></FONT> </P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN style=3D"mso-spacerun: yes"> =
</SPAN>' PRINT AND=20
EXIT</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial=20
size=3D2></FONT> </P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes"> =20
</SPAN>Application.PrintOut FileName:=3D"", =
Range:=3DwdPrintAllDocument, Item:=3D=20
_</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes"> =20
</SPAN>wdPrintDocumentContent, Copies:=3D1, Pages:=3D"",=20
PageType:=3DwdPrintAllPages, _</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes"> =20
</SPAN>ManualDuplexPrint:=3DFalse, Collate:=3DTrue, =
Background:=3DFalse,=20
PrintToFile:=3D _</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes"> =20
</SPAN>False, PrintZoomColumn:=3D0, PrintZoomRow:=3D0, =
PrintZoomPaperWidth:=3D0,=20
_</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes"> =20
</SPAN>PrintZoomPaperHeight:=3D0</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN style=3D"mso-spacerun: yes"> =20
</SPAN>ActiveDocument.Close=20
SaveChanges:=3DwdDoNotSaveChanges</FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2><SPAN style=3D"mso-spacerun: yes"> =20
</SPAN>Application.Quit SaveChanges:=3DwdDoNotSaveChanges<SPAN=20
style=3D"mso-spacerun: yes"> =20
</SPAN></FONT></FONT></P></BLOCKQUOTE></BLOCKQUOTE>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2><STRONG> Thanks to RM, I have successfully revised as =
follows, but=20
it's jamming with my Application.PrintOut options in bold=20
below:</STRONG></FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2></FONT></o:p> </P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2>Public Function Env()</FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2> Dim wd As Object<BR> Dim =
wdActiveDoc=20
As Object 'RM: Added this to help ensure that=20
you're<BR> &nb=
sp; &nbs=
p; =20
'working on the document you intend to.<BR> Dim =
wdField As=20
Object 'RM: Note the change in name here to=20
avoid<BR> &nbs=
p;  =
; =20
'ambiguity with the Field object in both Word=20
and<BR> =
&=
nbsp; =20
'Access. As well, I changed the type,=20
since<BR> &nbs=
p;  =
; =20
'(like Word.Application), you have to use=20
late<BR>  =
; =
=20
'binding.<BR> <BR> Set wd =3D=20
CreateObject("Word.Application")<BR> wd.Visible =3D=20
True</FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2> wd.Application.ScreenUpdating =3D=20
False<BR> <BR> Set wdActiveDoc =3D=20
wd.Documents.Open("K:\legalper\mergform.doc", False, False,=20
_<BR> &n=
bsp; =20
False, "", "", False, "", "", 0)<BR> =
<BR> =20
With wdActiveDoc.MailMerge<BR> =
.Destination =3D 0<BR> =20
.Execute<BR> End With<BR> =20
wd.Windows("mergform.doc").Activate<BR> =
wd.ActiveWindow.Close=20
0</FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2></FONT></o:p> </P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2> ' PRINT AND EXIT: <STRONG>PLEASE HELP ME=20
HERE:</STRONG></FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2></FONT></o:p> </P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2> <STRONG> =20
wd.Application.PrintOut =3D "", 0, 0, 1, "", 0, False, True, False,=20
_<BR> False, 0, 0, 0,=20
0</STRONG></FONT></o:p></P></DIV></BODY></HTML>
------=_NextPart_000_0006_01C83365.540730D0--