Reply
 
Thread Tools Display Modes
  #1   Report Post  
kbgrunt
 
Posts: n/a
Default can macro open file, print and close Word

With help from Jay Freedman I now have a macro that I am using inside a batch
file
to open an ASCII text file from a unix system, and compress the print.

Is it possible to take it a step further and actually print the file then
close Word?

This is the basic macro so far, I have added some margin settings...

Public Sub SetupReport()
Documents.Open "C:\docs\wide.txt"
ActiveDocument.PageSetup.Orientation = wdOrientLandscape
With ActiveDocument.Range
.Font.Name = "Courier New"
.Font.Size = 7
End With
End Sub

Thanks.
  #2   Report Post  
Shauna Kelly
 
Posts: n/a
Default

Hi kbgrunt

Assuming that you don't need to save the changes you've made, the following
should work:

Public Sub SetupReport()
Documents.Open "d:\d\test\test1.doc"
With ActiveDocument
.PageSetup.Orientation = wdOrientLandscape
With .Range
.Font.Name = "Courier New"
.Font.Size = 7
End With
.PrintOut
End With
Application.Quit SaveChanges:=wdDoNotSaveChanges
End Sub

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"kbgrunt" wrote in message
...
With help from Jay Freedman I now have a macro that I am using inside a
batch
file
to open an ASCII text file from a unix system, and compress the print.

Is it possible to take it a step further and actually print the file then
close Word?

This is the basic macro so far, I have added some margin settings...

Public Sub SetupReport()
Documents.Open "C:\docs\wide.txt"
ActiveDocument.PageSetup.Orientation = wdOrientLandscape
With ActiveDocument.Range
.Font.Name = "Courier New"
.Font.Size = 7
End With
End Sub

Thanks.



  #3   Report Post  
kbgrunt
 
Posts: n/a
Default

Shauna, thanks for the help. If I add just the .PrintOut the document
prints. If I add both the PrintOut and Application.Quit - Word opens, see
the document, the document closes then Word hangs with a blank grey window
and the report never prints. My guess is that Word is attempting to quit
while report is still printing.

Is there a way to pause/wait/sleep to allow report time to spool/print,
before Word attempts to quit?
Windows XP Pro, Word 2000. Will use this with Word 2000-2003.

Thanks

"Shauna Kelly" wrote:

Hi kbgrunt

Assuming that you don't need to save the changes you've made, the following
should work:

Public Sub SetupReport()
Documents.Open "d:\d\test\test1.doc"
With ActiveDocument
.PageSetup.Orientation = wdOrientLandscape
With .Range
.Font.Name = "Courier New"
.Font.Size = 7
End With
.PrintOut
End With
Application.Quit SaveChanges:=wdDoNotSaveChanges
End Sub

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"kbgrunt" wrote in message
...
With help from Jay Freedman I now have a macro that I am using inside a
batch
file
to open an ASCII text file from a unix system, and compress the print.

Is it possible to take it a step further and actually print the file then
close Word?

This is the basic macro so far, I have added some margin settings...

Public Sub SetupReport()
Documents.Open "C:\docs\wide.txt"
ActiveDocument.PageSetup.Orientation = wdOrientLandscape
With ActiveDocument.Range
.Font.Name = "Courier New"
.Font.Size = 7
End With
End Sub

Thanks.




  #4   Report Post  
Doug Robbins
 
Posts: n/a
Default

Use

..PrintOut Background:=False

That will prevent the next command in the macro from being executed until
the document has finished printing.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
"kbgrunt" wrote in message
...
Shauna, thanks for the help. If I add just the .PrintOut the document
prints. If I add both the PrintOut and Application.Quit - Word opens, see
the document, the document closes then Word hangs with a blank grey window
and the report never prints. My guess is that Word is attempting to quit
while report is still printing.

Is there a way to pause/wait/sleep to allow report time to spool/print,
before Word attempts to quit?
Windows XP Pro, Word 2000. Will use this with Word 2000-2003.

Thanks

"Shauna Kelly" wrote:

Hi kbgrunt

Assuming that you don't need to save the changes you've made, the
following
should work:

Public Sub SetupReport()
Documents.Open "d:\d\test\test1.doc"
With ActiveDocument
.PageSetup.Orientation = wdOrientLandscape
With .Range
.Font.Name = "Courier New"
.Font.Size = 7
End With
.PrintOut
End With
Application.Quit SaveChanges:=wdDoNotSaveChanges
End Sub

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"kbgrunt" wrote in message
...
With help from Jay Freedman I now have a macro that I am using inside a
batch
file
to open an ASCII text file from a unix system, and compress the print.

Is it possible to take it a step further and actually print the file
then
close Word?

This is the basic macro so far, I have added some margin settings...

Public Sub SetupReport()
Documents.Open "C:\docs\wide.txt"
ActiveDocument.PageSetup.Orientation = wdOrientLandscape
With ActiveDocument.Range
.Font.Name = "Courier New"
.Font.Size = 7
End With
End Sub

Thanks.






Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! I'm getting error messages too much-can't open Resume Wizard LizLB Microsoft Word Help 0 May 3rd 05 01:46 AM
Envelope Address GR New Users 5 April 24th 05 09:48 PM
Templates gman Page Layout 17 April 22nd 05 06:35 PM
word print dialog box delay mark Microsoft Word Help 2 January 23rd 05 07:09 PM
word xp crashes after macros are recorded kharris0405 Microsoft Word Help 3 January 11th 05 10:50 PM


All times are GMT +1. The time now is 03:03 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"