Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
#DIV/0 #DIV/0 is offline
external usenet poster
 
Posts: 7
Default Print all documents AND run a macro

Hi,
I've found the print-all-documents on the MVPS site but I want more!
:-)
For every document in a specific folder I need to:
- open each file and put the filename (with path) on the bottom line
- print the doc
- close it without saving the changes

--
David M
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Print all documents AND run a macro

This is almost the same requirement for which I posted a solution
yesterday -

Sub PrintWithAddedNames()
On Error GoTo err_FolderContents
Dim FirstLoop As Boolean
Dim DocList As String
Dim DocDir As String

With Dialogs(wdDialogCopyFile)
If .Display 0 Then
DocDir = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
If Documents.Count 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
Application.ScreenUpdating = False
FirstLoop = True
If Left(DocDir, 1) = Chr(34) Then
DocDir = Mid(DocDir, 2, Len(DocDir) - 2)
End If
DocList = Dir$(DocDir & "*.doc")
Do While DocList ""
Documents.Open DocList
Selection.EndKey Unit:=wdStory
Selection.TypeText vbCr & ActiveDocument.FullName
ActiveDocument.PrintOut
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
DocList = Dir$()
FirstLoop = False
Loop
Application.ScreenUpdating = True
Exit Sub
err_FolderContents:
MsgBox Err.Description
Exit Sub
End Sub

The macro will prompt for the folder then will open each *.doc in that
folder, add the filename and path to the bottom, print to the current active
printer then close without saving. It would be advisable to test with a
folder containing only one document to ensure it gives the required results.


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


#DIV/0 wrote:
Hi,
I've found the print-all-documents on the MVPS site but I want more!
:-)
For every document in a specific folder I need to:
- open each file and put the filename (with path) on the bottom line
- print the doc
- close it without saving the changes



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
#DIV/0 #DIV/0 is offline
external usenet poster
 
Posts: 7
Default Print all documents AND run a macro

I'm sorry I didn't see yesterday's post (although the code is similar the
query was about saving as pdf not printing so I think I can be forgiven).
I'd got as far as getting to the end of the doc, inserting the filename and
closing without saving - the easy part - I just couldn't figure out how to
get the folder contents into an array that I could then address.
Thanks a million - we have nearly a thousand docs and about half of them are
out of date. Now I can print them all, show them to the technicians and when
they say "no good - delete it" I don't have to spend hours opening random
files trying to find the bad one.

--
David M


"Graham Mayor" wrote:

This is almost the same requirement for which I posted a solution
yesterday -

Sub PrintWithAddedNames()
On Error GoTo err_FolderContents
Dim FirstLoop As Boolean
Dim DocList As String
Dim DocDir As String

With Dialogs(wdDialogCopyFile)
If .Display 0 Then
DocDir = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
If Documents.Count 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
Application.ScreenUpdating = False
FirstLoop = True
If Left(DocDir, 1) = Chr(34) Then
DocDir = Mid(DocDir, 2, Len(DocDir) - 2)
End If
DocList = Dir$(DocDir & "*.doc")
Do While DocList ""
Documents.Open DocList
Selection.EndKey Unit:=wdStory
Selection.TypeText vbCr & ActiveDocument.FullName
ActiveDocument.PrintOut
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
DocList = Dir$()
FirstLoop = False
Loop
Application.ScreenUpdating = True
Exit Sub
err_FolderContents:
MsgBox Err.Description
Exit Sub
End Sub

The macro will prompt for the folder then will open each *.doc in that
folder, add the filename and path to the bottom, print to the current active
printer then close without saving. It would be advisable to test with a
folder containing only one document to ensure it gives the required results.


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


#DIV/0 wrote:
Hi,
I've found the print-all-documents on the MVPS site but I want more!
:-)
For every document in a specific folder I need to:
- open each file and put the filename (with path) on the bottom line
- print the doc
- close it without saving the changes




  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Print all documents AND run a macro

It wasn't a criticism, but an observation

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


#DIV/0 wrote:
I'm sorry I didn't see yesterday's post (although the code is similar
the query was about saving as pdf not printing so I think I can be
forgiven). I'd got as far as getting to the end of the doc, inserting
the filename and closing without saving - the easy part - I just
couldn't figure out how to get the folder contents into an array that
I could then address.
Thanks a million - we have nearly a thousand docs and about half of
them are out of date. Now I can print them all, show them to the
technicians and when they say "no good - delete it" I don't have to
spend hours opening random files trying to find the bad one.


This is almost the same requirement for which I posted a solution
yesterday -

Sub PrintWithAddedNames()
On Error GoTo err_FolderContents
Dim FirstLoop As Boolean
Dim DocList As String
Dim DocDir As String

With Dialogs(wdDialogCopyFile)
If .Display 0 Then
DocDir = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
If Documents.Count 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
Application.ScreenUpdating = False
FirstLoop = True
If Left(DocDir, 1) = Chr(34) Then
DocDir = Mid(DocDir, 2, Len(DocDir) - 2)
End If
DocList = Dir$(DocDir & "*.doc")
Do While DocList ""
Documents.Open DocList
Selection.EndKey Unit:=wdStory
Selection.TypeText vbCr & ActiveDocument.FullName
ActiveDocument.PrintOut
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
DocList = Dir$()
FirstLoop = False
Loop
Application.ScreenUpdating = True
Exit Sub
err_FolderContents:
MsgBox Err.Description
Exit Sub
End Sub

The macro will prompt for the folder then will open each *.doc in
that folder, add the filename and path to the bottom, print to the
current active printer then close without saving. It would be
advisable to test with a folder containing only one document to
ensure it gives the required results.


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


#DIV/0 wrote:
Hi,
I've found the print-all-documents on the MVPS site but I want more!
:-)
For every document in a specific folder I need to:
- open each file and put the filename (with path) on the bottom line
- print the doc
- close it without saving the changes



  #5   Report Post  
Posted to microsoft.public.word.docmanagement
#DIV/0 #DIV/0 is offline
external usenet poster
 
Posts: 7
Default Print all documents AND run a macro

I just wanted to thank Graham again a year later. This macro (and the hours I
spent working out just what he'd done) really helped with my understanding of
"With" and loops, functions I now use regularly.

--
David M
WinXP - Office2003 (Italian)


"Graham Mayor" wrote:

It wasn't a criticism, but an observation

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


#DIV/0 wrote:
I'm sorry I didn't see yesterday's post (although the code is similar
the query was about saving as pdf not printing so I think I can be
forgiven). I'd got as far as getting to the end of the doc, inserting
the filename and closing without saving - the easy part - I just
couldn't figure out how to get the folder contents into an array that
I could then address.
Thanks a million - we have nearly a thousand docs and about half of
them are out of date. Now I can print them all, show them to the
technicians and when they say "no good - delete it" I don't have to
spend hours opening random files trying to find the bad one.


This is almost the same requirement for which I posted a solution
yesterday -

Sub PrintWithAddedNames()
On Error GoTo err_FolderContents
Dim FirstLoop As Boolean
Dim DocList As String
Dim DocDir As String

With Dialogs(wdDialogCopyFile)
If .Display 0 Then
DocDir = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
If Documents.Count 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
Application.ScreenUpdating = False
FirstLoop = True
If Left(DocDir, 1) = Chr(34) Then
DocDir = Mid(DocDir, 2, Len(DocDir) - 2)
End If
DocList = Dir$(DocDir & "*.doc")
Do While DocList ""
Documents.Open DocList
Selection.EndKey Unit:=wdStory
Selection.TypeText vbCr & ActiveDocument.FullName
ActiveDocument.PrintOut
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
DocList = Dir$()
FirstLoop = False
Loop
Application.ScreenUpdating = True
Exit Sub
err_FolderContents:
MsgBox Err.Description
Exit Sub
End Sub

The macro will prompt for the folder then will open each *.doc in
that folder, add the filename and path to the bottom, print to the
current active printer then close without saving. It would be
advisable to test with a folder containing only one document to
ensure it gives the required results.


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


#DIV/0 wrote:
Hi,
I've found the print-all-documents on the MVPS site but I want more!
:-)
For every document in a specific folder I need to:
- open each file and put the filename (with path) on the bottom line
- print the doc
- close it without saving the changes






  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Print all documents AND run a macro

Flattery will get you everywhere

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


#DIV/0 wrote:
I just wanted to thank Graham again a year later. This macro (and the
hours I spent working out just what he'd done) really helped with my
understanding of "With" and loops, functions I now use regularly.


It wasn't a criticism, but an observation

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


#DIV/0 wrote:
I'm sorry I didn't see yesterday's post (although the code is
similar the query was about saving as pdf not printing so I think I
can be forgiven). I'd got as far as getting to the end of the doc,
inserting the filename and closing without saving - the easy part -
I just couldn't figure out how to get the folder contents into an
array that I could then address.
Thanks a million - we have nearly a thousand docs and about half of
them are out of date. Now I can print them all, show them to the
technicians and when they say "no good - delete it" I don't have to
spend hours opening random files trying to find the bad one.


This is almost the same requirement for which I posted a solution
yesterday -

Sub PrintWithAddedNames()
On Error GoTo err_FolderContents
Dim FirstLoop As Boolean
Dim DocList As String
Dim DocDir As String

With Dialogs(wdDialogCopyFile)
If .Display 0 Then
DocDir = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
If Documents.Count 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
Application.ScreenUpdating = False
FirstLoop = True
If Left(DocDir, 1) = Chr(34) Then
DocDir = Mid(DocDir, 2, Len(DocDir) - 2)
End If
DocList = Dir$(DocDir & "*.doc")
Do While DocList ""
Documents.Open DocList
Selection.EndKey Unit:=wdStory
Selection.TypeText vbCr & ActiveDocument.FullName
ActiveDocument.PrintOut
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
DocList = Dir$()
FirstLoop = False
Loop
Application.ScreenUpdating = True
Exit Sub
err_FolderContents:
MsgBox Err.Description
Exit Sub
End Sub

The macro will prompt for the folder then will open each *.doc in
that folder, add the filename and path to the bottom, print to the
current active printer then close without saving. It would be
advisable to test with a folder containing only one document to
ensure it gives the required results.


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


#DIV/0 wrote:
Hi,
I've found the print-all-documents on the MVPS site but I want
more! :-)
For every document in a specific folder I need to:
- open each file and put the filename (with path) on the bottom
line
- print the doc
- close it without saving the changes



Reply
Thread Tools
Display Modes

Posting Rules

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

Forum Jump


All times are GMT +1. The time now is 01:10 PM.

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"