Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-10-2018, 05:39 AM
lipatin lipatin is offline Auto generate X pages from input Windows 7 64bit Auto generate X pages from input Office 2010 64bit
Novice
Auto generate X pages from input
 
Join Date: Apr 2018
Posts: 6
lipatin is on a distinguished road
Default Auto generate X pages from input

Hi

I am trying to figure out a way to create X number of pages from a single input value in my Word document.

Example:

Input value 5 units of -> create 5 new Word pages.

Has anybody experience with this matter?



Best regards!
Reply With Quote
  #2  
Old 04-10-2018, 06:31 AM
gmayor's Avatar
gmayor gmayor is offline Auto generate X pages from input Windows 10 Auto generate X pages from input Office 2016
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

You are going to have to be clearer what it is that you want to achieve with regard to 'pages'. There are no 'pages' in a Word document. Word is not a page layout application. You could insert five page breaks (see macro), but what would be the point of that?

Code:
Sub Macro1()
Dim i As Integer
Dim strPages As String
    strPages = InputBox("How many pages?", , 5)
    If IsNumeric(strPages) = False Then Exit Sub
    If Not strPages = "" Then
        For i = 1 To Val(strPages)
            Selection.InsertBreak wdPageBreak
        Next i
    End If
End Sub
__________________
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 04-10-2018, 07:08 AM
lipatin lipatin is offline Auto generate X pages from input Windows 7 64bit Auto generate X pages from input Office 2010 64bit
Novice
Auto generate X pages from input
 
Join Date: Apr 2018
Posts: 6
lipatin is on a distinguished road
Default

What I am trying to achieve is a document layout where I can input a value of e.g. 5 on my first page, which then generates 5 new pages.

The 5 new pages are then created with title Unit 1, Unit 2, Unit 3, Unit 4, Unit 5
Reply With Quote
  #4  
Old 04-10-2018, 06:39 PM
Guessed's Avatar
Guessed Guessed is offline Auto generate X pages from input Windows 10 Auto generate X pages from input Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I think this should be done with a combination of style and macro.
If you customised a style in your document to provide the 'Unit #' as an autonumber and include the "new page" setting then the macro could be as simple as
Code:
Sub AddPages()
  Dim iNum As Integer
  iNum = Val(InputBox("How many units are you adding?", , 5))
  If iNum > 0 Then
    Selection.Style = "Heading 1"
    Selection.TypeText String(iNum, vbCr)
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 04-10-2018, 10:15 PM
macropod's Avatar
macropod macropod is offline Auto generate X pages from input Windows 7 64bit Auto generate X pages from input Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See, for example:
https://www.msofficeforums.com/word-...html#post34477
https://www.msofficeforums.com/word-...html#post33829
https://www.msofficeforums.com/word-...tml#post113655
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 05-01-2018, 02:09 AM
lipatin lipatin is offline Auto generate X pages from input Windows 7 64bit Auto generate X pages from input Office 2010 64bit
Novice
Auto generate X pages from input
 
Join Date: Apr 2018
Posts: 6
lipatin is on a distinguished road
Default

Thanks for the responses!

I have tried to configure it using both of your suggestions, however what I am missing is creating a interactive field on a line as illustrated on the attached document, where the user can input a desired value of units from where it autogenerates the new pages with the content of the starting page "Unit 1" but with new indices unit 2, unit 3 and etc. ?

Is this possible?
Attached Files
File Type: docm Addpages.docm (23.7 KB, 15 views)
Reply With Quote
  #7  
Old 05-01-2018, 03:24 PM
macropod's Avatar
macropod macropod is offline Auto generate X pages from input Windows 7 64bit Auto generate X pages from input Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The first link I posted shows how to do that where all pages have the same content except for the numbers.
The second link I posted shows how to do it for the purposes of generating printouts only.
The third link I posted supplies a macro to do it for the purposes of generating PDFs only.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 05-07-2018, 01:27 AM
lipatin lipatin is offline Auto generate X pages from input Windows 7 64bit Auto generate X pages from input Office 2010 64bit
Novice
Auto generate X pages from input
 
Join Date: Apr 2018
Posts: 6
lipatin is on a distinguished road
Default

Hi macropod

I have looked at the first post you refer to which have some similarities to what I am trying to achieve with my document (attached addpages.docm), however I still miss the link to create a functionality where I can click on the line in "No. of Units" from where it runs a macro asking "how many units?" and then generate the desired quantity of pages with the content from page 2 in the attached file. Finally it then writes the selected quantity on the line "No. of Units".

Best regards
Reply With Quote
  #9  
Old 05-07-2018, 04:33 AM
macropod's Avatar
macropod macropod is offline Auto generate X pages from input Windows 7 64bit Auto generate X pages from input Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

With the template in the first link, you don't type anything into the document - the macro takes care of all numbering. If you let that macro run and input some appropriate values, you will see that the document will automatically have the required number of pages with the number range specified.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 05-07-2018, 06:01 AM
lipatin lipatin is offline Auto generate X pages from input Windows 7 64bit Auto generate X pages from input Office 2010 64bit
Novice
Auto generate X pages from input
 
Join Date: Apr 2018
Posts: 6
lipatin is on a distinguished road
Default

I know, but I dont want the macro to run as soon as I open the document. Have you looked at the document I have uploaded in the #6 thread of the posts called addpages.docm and understood what I want to achieve?

Example:
If a person opens the document "addpages.docm" and clicks on the grey line "No. of Units" the macro runs and ask "how many units". The user then puts in 5, as an example, from where the macro creates 5 pages of the page "2" content in the document and updates the Unit numbering starting with Unit 1 and ending with 5.
Reply With Quote
  #11  
Old 05-07-2018, 03:58 PM
macropod's Avatar
macropod macropod is offline Auto generate X pages from input Windows 7 64bit Auto generate X pages from input Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by lipatin View Post
I know, but I dont want the macro to run as soon as I open the document. Have you looked at the document I have uploaded in the #6 thread of the posts called addpages.docm and understood what I want to achieve?
Of course I did. I fail to see how what you're asking for is fundamentally different in outcome, except that your approach doesn't allow the user to nominate the starting #.

The nearest you'll get to what you've described is with something like the attached. The macro runs after you input the number into the formfield, then tab out of it. To get the numbering to update, it is necessary for that part, at least, to be in the page header.
Attached Files
File Type: docm Addpages.docm (31.6 KB, 17 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 05-31-2018, 11:14 PM
lipatin lipatin is offline Auto generate X pages from input Windows 7 64bit Auto generate X pages from input Office 2010 64bit
Novice
Auto generate X pages from input
 
Join Date: Apr 2018
Posts: 6
lipatin is on a distinguished road
Default

This works very well, thank you macropod!

One thing I noticed though was, when you enter a value for example 2 it generates the 2 pages properly, however if then the value was wrong and you want to change it to 4 the macro creates 2 x 4 pages instead of 4.

Is this something that can be corrected?
Reply With Quote
  #13  
Old 06-01-2018, 12:13 AM
macropod's Avatar
macropod macropod is offline Auto generate X pages from input Windows 7 64bit Auto generate X pages from input Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Presumably, that's because you've already generated 2 pages before inputting the 4. The macro works by replicating the existing content. So, if you want to double the page count, simply re-input the 2; otherwise close the document & start over.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto generate X pages from input Auto-correct on existing text without input m9rbid Word 1 12-18-2017 01:20 PM
How to auto-generate whole Powerpoint presentations from a set of data? olibot2000 PowerPoint 1 06-24-2017 09:01 PM
Automatically generate formulas from just the row numbers (auto insert the column) knewman Excel 14 04-25-2017 11:54 PM
Crash after power failure. Doc is now blank and appears to auto-generate as a new doc on opening Jbobjones Word 0 04-28-2015 09:37 PM
Auto Generate Invoice Number Word 2013 Jonah245 Word VBA 3 09-04-2014 05:24 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:44 PM.


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