Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-14-2014, 07:46 AM
pizzaman1 pizzaman1 is offline Macro for word to add page break and specific text to end of document Windows 7 64bit Macro for word to add page break and specific text to end of document Office 2007
Novice
Macro for word to add page break and specific text to end of document
 
Join Date: Nov 2014
Posts: 3
pizzaman1 is on a distinguished road
Default Macro for word to add page break and specific text to end of document

I am looking to create a macro that can be used to add specific text to the end of several documents contained in a specific folder and the subfolders.

At the current end of the document I would like a page break and then specific text added. I was thinking it may be easier to paste the text from the clipboard so that formatting can be maintained. However if it is easier the text can be specified in the macro.

Thank yo
Reply With Quote
  #2  
Old 11-14-2014, 08:02 AM
gmayor's Avatar
gmayor gmayor is offline Macro for word to add page break and specific text to end of document Windows 7 64bit Macro for word to add page break and specific text to end of document Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The Word add-in at http://www.gmayor.com/document_batch_processes.htm will handle the backroom tasks relating to the folders and sub folder processing and it is then a relatively simple process to create a custom function to run from the add-in to insert a specific text at the end, either from the clipboard, or from text saved as an autotext entry or directly from text defined in the function e.g. Using an Autotext entry

Function AddAPage(oDoc As Document) As Boolean
Dim oRng As Range
On Error GoTo Err_Handler
Set oRng = oDoc.Range
oRng.Collapse 0
oRng.InsertBreak wdPageBreak
Set oRng = oDoc.Range
oRng.Collapse 0
Application.Templates("Normal.dotm"). _
BuildingBlockEntries("AutoTextName").Insert _
Where:=oRng, _
RichText:=True
AddAPage = True
lbl_Exit:
Exit Function
Err_Handler:
AddAPage = False
Resume lbl_Exit
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 11-14-2014, 08:09 AM
pizzaman1 pizzaman1 is offline Macro for word to add page break and specific text to end of document Windows 7 64bit Macro for word to add page break and specific text to end of document Office 2007
Novice
Macro for word to add page break and specific text to end of document
 
Join Date: Nov 2014
Posts: 3
pizzaman1 is on a distinguished road
Default

I am not familiar with the AutoTextName function. I am new to the use of VBA.

If I wanted to insert text that says what is below what would I need to do.

Changes:
__________________________________________________ ______
Blah Blah Balh
Reply With Quote
  #4  
Old 11-14-2014, 08:27 AM
gmaxey gmaxey is offline Macro for word to add page break and specific text to end of document Windows 7 32bit Macro for word to add page break and specific text to end of document Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Code:
Function AddAPage(oDoc As Document) As Boolean
Dim oRng As Range
On Error GoTo Err_Handler
Set oRng = oDoc.Range
oRng.Collapse 0
oRng.InsertBreak wdPageBreak
Set oRng = oDoc.Range
oRng.Collapse 0
oRng.Text = "Changes: " & vbCr _
           & "_________________________________________________________________" & vbCr _
           & "Blah, blah, blah."
AddAPage = True
lbl_Exit:
Exit Function
Err_Handler:
AddAPage = False
Resume lbl_Exit
End Function
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 11-14-2014, 08:51 AM
gmayor's Avatar
gmayor gmayor is offline Macro for word to add page break and specific text to end of document Windows 7 64bit Macro for word to add page break and specific text to end of document Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Quote:
Originally Posted by pizzaman1 View Post
I am not familiar with the AutoTextName function. I am new to the use of VBA.
AutoTextName is not a function, it's the name of the autotext entry containing the data that you wish to add. i.e. Insert the text in a document, select it and press ALT+F3, save it with a suitable name in the normal template, and then replace AutoTextName with that name you have chosen.

Or as the text appears short, you could use Greg's suggestion to insert it directly.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #6  
Old 11-14-2014, 08:53 AM
pizzaman1 pizzaman1 is offline Macro for word to add page break and specific text to end of document Windows 7 64bit Macro for word to add page break and specific text to end of document Office 2007
Novice
Macro for word to add page break and specific text to end of document
 
Join Date: Nov 2014
Posts: 3
pizzaman1 is on a distinguished road
Default

Thank you, sorry for being dumb, but I how do get it in the normal template.
Reply With Quote
  #7  
Old 11-14-2014, 11:25 PM
gmayor's Avatar
gmayor gmayor is offline Macro for word to add page break and specific text to end of document Windows 7 64bit Macro for word to add page break and specific text to end of document Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

When you press ALT+F3 to save the autotext entry, by default Word 2007 wants to put the entry in the QuickParts gallery of Building Blocks.dotx
Click the dropdown adjacent to Gallery and select Autotext and similarly click the dropdown agains Save In and select Normal.dotm. Then OK.
Depending on whether you have Word configured to automatically save the normal template on Close, you may get a prompt to save the template when you close Word. That autotext entry will remain unless Word is closed without saving the template.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for word to add page break and specific text to end of document Macro to insert multiple pictures to word to a specific size and text wrap mescaL Word VBA 3 11-03-2014 10:51 PM
Page Break based on specific work mbesspiata Word 6 01-22-2014 12:40 PM
Macro for word to add page break and specific text to end of document Add Page Break to Document expatchic Word VBA 5 08-08-2012 04:16 PM
Macro for word to add page break and specific text to end of document Deleteing specific text in word document ubns Word 1 05-31-2012 10:38 PM
Macro for word to add page break and specific text to end of document WORD Macro - import picture - resize - position - page break - loop Nano07 Word VBA 2 11-02-2011 05:14 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:15 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft