-
WSsolomod
AskWoody LoungerOctober 16, 2002 at 10:22 am in reply to: Macro: print each sheet to pdf using sheet name as (Excel 97 sr-2 Win95) #624573Many thanks Hans – worked a treat. I just have to fine-tune the SendKeys to get then in the right directory.
However I am going to be sent a large number of workbooks every month to convert – is there any way of tying the macro to Excel instead of a particular workbook – as in normal.dot in Word? I don’t want to have to paste the macro into every workbook.
David
-
WSsolomod
AskWoody LoungerAlthough you can complete and print forms in Reader you cannot save the form+data to disc. In Reader you can only submit the field data to a server.
David
-
WSsolomod
AskWoody Lounger(Edited by gwhitfield on 28-Sep-02 07:02. Hyperlinks added)
I would use a userform – see here for more info:
http://www.mvps.org/word/FAQs/Userforms/CreateAUserForm.htm%5B/url%5D
-
WSsolomod
AskWoody LoungerThe easy answer is don’t use Word. Word is a page or document processor and is no good at making publications. I’ve spent a large chunk of my life writing manuals and I’d advise you to go out and buy Ventura or Framemaker and do the job properly. It’s a lot easier in the long run.
Ventura works like a “shell” – you tell it that a manual is composed of files a, b & c and it assembles them, formats and constructs indexes etc across the whole publication. So if chapter B is present in all pubs it’s easy. And you can amend chapter b in whatever processor you fancy and Ventura will always use the latest version.
David
-
WSsolomod
AskWoody LoungerYes – big sigh, so early in the morning too.
We inherited this system some years ago and only in this week have we been asked for information.
Going to sit down now and see if there is some way of pulling the specific document code info together. Looks like the start of another learning curve.
Thanks for your help Hans – spent some days near Amsterdam last year – really envy you your on the flat cycling.
David
-
WSsolomod
AskWoody LoungerYou could try building the whole thing with a macro. We have a letter that uses a mailmerge from an Access database and writes the letter text as it goes. If you were to record a macro adding the fields you could add this in at the end of the merge.
I have attached our letter macro to this post. It’s very specialised but it does 2 merges and inserts mailmerge fields so you might be able to make use of bits of it. Very clumsy scripting I’m afraid but I’m still on the learning curve.
David
-
WSsolomod
AskWoody LoungerPhil,
I do this all the time for our intranet. I use a control button located in a text frame for the e-mail button and a script from Chris Rae to e-mail.
The code for the buttons:
Private Sub link_to_index_Click()
ActiveDocument.FollowHyperlink Address:= _
“aide_memoire.htm”, NewWindow:=False _
, AddHistory:=TrueEnd Sub
Private Sub print_form_Click()
With ActiveDocument
.Shapes(1).Visible = msoFalse
.PrintOut Background:=False
.Shapes(1).Visible = msoTrueEnd With
End Sub
Private Sub send_form_Click()
MailDoc3
End Sub
Button 1 returns the user to the document index, button 2 prints the form without showing the button bar and 3 e-mails the form using the script below:
Sub MailDoc3()
ActiveDocument.SaveAs FileName:=”bsg402.doc”
‘ Make instance
Set myOutlook = CreateObject(“Outlook.Application”)
‘ Make mail item
Set myMailItem = myOutlook.createitem(0)
‘ Set recipient (internal mail)myMailItem.Recipients.Add “Stroud, Phyl”
myMailItem.Recipients.Add “Jones, Christine (SW)”myMailItem.Recipients.Add “Humanresources”
myMailItem.Recipients.Add “SWSITESECURITY”‘ Set subject
myMailItem.Subject = “Starters & Leavers – Team Managers”
‘ Set body
myMailItem.body = “The attached form BSG 402 contains personnel details for your attention.”
‘ Set open doc as attachement
myMailItem.Attachments.Add ActiveDocument.FullName
‘ And send it!
myMailItem.send
‘ Close instance
Set myOutlook = NothingEnd Sub
The mail macro came from Chris Rae here
http://chrisrae.com/vba/routines/sendmail.html%5B/url%5D
and the non-printing button bar from the MVP web:
http://www.mvps.org/word/FAQs/TblsFldsFms/…PrintButton.htm%5B/url%5D
David
-
WSsolomod
AskWoody LoungerThanks very much for the help – printed them off and in my “Useful Tips file”.
David
-
WSsolomod
AskWoody LoungerI would use a userform to fill in the field and use the Close button to look at the field to see if anything has been entered. See how to build a userform here:
http://www.mvps.org/word/FAQs/Userforms/CreateAUserForm.htm
The code below is my version of the close button:
Private Sub tel_num_close_Click()
Dim validate(0)
‘ Check for entry in tel num field
validate(0) = ActiveDocument.FormFields(“tel_num”).ResultIf validate(0) = “” Then
MsgBox “You must enter a number”
End If
If validate(0) “” Then
End
End If
End Sub
It’s not foolproof but it works.
David
-
WSsolomod
AskWoody LoungerThanks Jefferson – worked a treat.
David
-
WSsolomod
AskWoody LoungerPhil,
I tried to use the mergefield technique but rapidly became confused with nested fields. In the end I discovered the catalog merge (courtesy of a Cindy Meister web article) and did a double mailmerge to produce the required doc. I have automated it with a macro.
The macro is listed below in case anybody else is interested. Half of it is recorded and other half my own scripting so I imagine it can be cleaned up a lot by someone who knows VBA. However, it’s quick and it works. I can now generate the letters off a toolbar button.
Example finished page attached.
Thanks to everybody for their tips.
David
Sub leavers_letter()
‘Open 1st doc in mailmerge catalogue mode
ChangeFileOpenDirectory “D:ManualsSYSTEMSaccess forms”
Documents.Open FileName:=”””test leavers.doc”””‘New doc generated from merge
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Execute
End With‘Header row added to table in new doc
Selection.GoTo What:=Cell, Name:=”a1″
Selection.InsertRows (1)
Selection.GoTo What:=Cell, Name:=”a1″
Selection.TypeText Text:=”System ID”
Selection.MoveRight Unit:=wdCharacter, count:=1
Selection.TypeText Text:=”Title”
Selection.MoveRight Unit:=wdCharacter, count:=1
Selection.TypeText Text:=”Copy”Selection.GoTo What:=Cell, Name:=”a1″
Selection.SelectRow
Selection.Font.Bold = wdToggle
Selection.Rows.HeadingFormat = wdToggle‘Cursor moved out of table to top of doc
Selection.GoTo What:=Cell, Name:=”a1″
Selection.SplitTable
Selection.TypeParagraph
Selection.TypeParagraph
Selection.MoveUp Unit:=wdLine, count:=2
Selection.TypeText Text:=”To:”
Selection.MoveDown Unit:=wdLine, count:=1‘New doc merged again to add addressee etc fields
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
“SW-0101976NINA DAccessDataDOCUMENT.MDB”, ConfirmConversions:=False _
, ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:=””, PasswordTemplate:=””, WritePasswordDocument:=””, _
WritePasswordTemplate:=””, Revert:=False, Format:=wdOpenFormatAuto, _
Connection:=”QUERY Leavers Letter”, SQLStatement:= _
“SELECT * FROM [Leavers Letter]”, SQLStatement1:=””
ActiveDocument.MailMerge.EditMainDocument
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
“employees_1First_Name”
Selection.TypeText Text:=” ”
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
“employees_1Last_Name”
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
“Dept_Name”
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
“Location_3Location”
Selection.TypeParagraph
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
“employeesFirst_Name”
Selection.TypeText Text:=” ”
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
“employeesLast_Name”
Selection.TypeParagraph‘Letter text added
Selection.TypeText Text:= _
“Document Control have been informed that the above employee ”
Selection.TypeText Text:= _
“has left the company. The documents issued to the above are ”
Selection.TypeText Text:=”listed below.”
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:= _
“Document Control would appreciate the return of these docume”
Selection.TypeText Text:=”nts.”‘ Mailmerged to form complete letter
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Execute
End With‘Merge will produce as many letters as there are records in the query.
‘Cursor set to start of page 2 and remaing doc selected‘count pages
Dim intpage As IntegerActiveDocument.Repaginate
intpage = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
‘MsgBox ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)‘if more than 1 page go to page 2
If intpage > 1 ThenSelection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, count:=2, Name:=””
Selection.Find.ClearFormatting
With Selection.Find
.Text = “page”
.Replacement.Text = ” ”
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With‘if only 1 page exit sub
Else
Exit SubEnd If
‘Selected text deleted
Selection.EndKey Unit:=wdStory, Extend:=wdExtend
Selection.delete Unit:=wdCharacter, count:=1
ActiveWindow.ActivePane.SmallScroll Down:=-24
Selection.TypeBackspace‘Backspace to delete new page section break
‘single page letter remainingSelection.delete Unit:=wdCharacter, count:=1
End Sub
-
WSsolomod
AskWoody LoungerAnn,
Fixed it, although it seems a bit of a fudge.
I discovered a DATABASE toolbar lurking at the top of the screen and used that instead. I abandoned mailmerge and inserted the data as fields. It meant I had to have 3 queries that each held just the information I required (addressee, employee concerned & list of manuals) but each query only has to have a number entered in it so it’s not too onerous.
But it works!
Thank you for your help,
David
-
WSsolomod
AskWoody LoungerThis switches the protection off:
ActiveDocument.Unprotect
This switxches it on:
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
David
-
WSsolomod
AskWoody LoungerI’ve this – rarely I’m glad to say! – on various docs.
There seems to be some error in the doc that causes it. I’ve got round it by:
a) Set the cursor at the very beginning of the doc and try a save;
or
Select all your text, copy to the clipboard and paste into a new doc;
or
c) Copy all the text to the clipboard, paste into a plain text editor and save as a text (.txt) file. That strips out everything that Word puts in. Open text file in Word and reformat.
David
-
WSsolomod
AskWoody LoungerI had a document (the source) containing the includetext fields that linked to three docs – the first two docs had one template and the last a different. All the docs were in the same folder.
The docs printed but all used the header & footers of the first doc and the last doc – with the different template – was all over the place.
David
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Two March KB5053606 updates? (Awaiting moderation)
by
Adam
2 hours, 3 minutes ago -
Two March KB5053606 updates? (Awaiting moderation)
by
Adam
2 hours, 4 minutes ago -
Intel® Graphics/Sound Driver updates for 7th-10th Gen Intel® Core™ Processor
by
Alex5723
2 hours, 29 minutes ago -
Is there a comprehensve way to tranfer ALL current Edge Settings into a new Edge
by
Tex265
8 hours, 41 minutes ago -
Transferring ALL info/settings from current Firefox to new computer Firefox
by
Tex265
10 hours, 4 minutes ago -
DOGE Wants to Replace SSA 60 Million Line COBOL Codebase in Months
by
EyesOnWindows
4 hours, 51 minutes ago -
KB5051989 Usb printer Post Ipp
by
licencesti
9 hours, 3 minutes ago -
Removing bypassnro
by
Susan Bradley
2 minutes ago -
Up to 30 seconds to show “Recent Topics”
by
PL1
13 hours, 24 minutes ago -
Sound changes after upgrade from W11 23H2
by
WStaylorpsepa
15 hours, 8 minutes ago -
Windows bug blocks BIOS updates for Lenovo ThinkPad laptops
by
Alex5723
18 hours, 11 minutes ago -
O&O Software – ‘World Backup Day’ Sale
by
unbob
14 hours, 31 minutes ago -
Still version 23H2?
by
WSbxcfilm
18 hours, 59 minutes ago -
Ubuntu 25.04 (Plucky Puffin) Beta released
by
Alex5723
1 day ago -
How to install App Store apps on an external SSD
by
Alex5723
1 day, 1 hour ago -
Where is Windows going?
by
Susan Bradley
16 hours, 6 minutes ago -
Installing Feature Update Windows 11 24H2
by
geekdom
1 day, 19 hours ago -
Windows 11 Insider Preview build 27823 released to Canary
by
joep517
1 day, 19 hours ago -
Windows 11 Hotpatch
by
Hackmuss
1 day, 3 hours ago -
System Guard service error still won’t be fixed
by
Susan Bradley
1 day, 20 hours ago -
Operation ForumTroll: APT attack with Google Chrome zero-day exploit chain
by
Alex5723
1 day, 14 hours ago -
Troy Hunt of HaveIBeenPwned Phished
by
Lars220
5 hours, 18 minutes ago -
Microsoft Windows security auditing Code 5061
by
mpw
2 days, 8 hours ago -
Can’t display images in incoming Outlook 365 emails
by
WScopwriter
1 day, 16 hours ago -
Windows 11 Insider Preview Build 26200.5510 early builds of 25H2
by
Alex5723
1 day, 17 hours ago -
0Patch : Micropatches released for SCF File NTLM Hash Disclosure Vulnerability
by
Alex5723
1 day, 17 hours ago -
Select multiple emails and they all open up!
by
CeeJay
3 days, 10 hours ago -
How to remove an update preview
by
Gunny
1 day, 12 hours ago -
Third party add ins reminder
by
Susan Bradley
19 hours, 32 minutes ago -
OTF, which backs Tor, Let’s Encrypt and more, sues to save its funding
by
Nibbled To Death By Ducks
3 days, 3 hours ago
Recent blog posts
- Removing bypassnro
- Where is Windows going?
- System Guard service error still won’t be fixed
- Third party add ins reminder
- MS-DEFCON 4: Mixed bag for March
- Classic and Extended Control Panel — no need to say goodbye
- Things you can do in 2025 that you couldn’t do in 2024
- Revisiting Windows 11’s File Explorer
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.