Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
|
Lista Forumurilor Pe Tematici
|
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login
POZE MRRRR'S FORUM (VIEW ONLY)
Nu sunteti logat.
|
Nou pe simpatie: adee
 | Femeie 24 ani Mures cauta Barbat 24 - 59 ani |
|
TRaP
Moderator
Inregistrat: acum 6 ani
Postari: 795
|
|
First, let's insert page number the old fashioned way (Insert - Page Number - Current Position - Page X of Y).
Now edit / customize the result to your desire (mine is Pagina 1 / 1), then select it, then go again to Insert - Page Number - Current Position and at the bottom of the list (not in the list itself) you will have to click on Save Selection to Page Number Gallery...
A new box will appear where you need to complete the following: Name: The name of your Building Block, eg Pagina X / Y --- you will need this name in your VBA code below. Gallery: Page Numbers Category: Page X of Y (in this case, you can select whatever fits your custom page number best) Description: optional Save in: Normal (I'd recommend it to be Normal because that's where all your macros are stored too) Options: Insert content only
Click OK
Now open VBA (ALT+F11), create a new module and paste the following:
Sub PageXofY()
Application.Templates _ ("C:\Users\CURRENT USER NAME\AppData\Roaming\Microsoft\Templates\Normal.dotm") _ .BuildingBlockEntries("Pagina X / Y").Insert Where:=Selection.Range, RichText:=True
End Sub |
Note that you have to replace CURRENT USER NAME with your user name, and Pagina X / Y with the name you defined before.
Modificat de TRaP (acum 6 ani)
|
|
pus acum 6 ani |
|
TRaP
Moderator
Inregistrat: acum 6 ani
Postari: 795
|
|
|
pus acum 6 ani |
|
Mrrrr
AdMiN
 Inregistrat: acum 18 ani
Postari: 2247
|
|
I used an even more advanced way of inserting a page number by creating a user form to do it in more than one way, by choice:
Private Sub CommandButton1_Click()
' INSERT PAGE NUMBERS IN THE FORM: Pag. X / Y With Word.Application.ActiveDocument Selection.TypeText Text:="Pag. " Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "PAGE ", PreserveFormatting:=True Selection.TypeText Text:=" / " Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "NUMPAGES ", PreserveFormatting:=True End With End Sub
Private Sub CommandButton2_Click()
' INSERT PAGE NUMBERS IN THE FORM: Pag. X din Y With Word.Application.ActiveDocument Selection.TypeText Text:="Pag. " Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "PAGE ", PreserveFormatting:=True Selection.TypeText Text:=" din " Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "NUMPAGES ", PreserveFormatting:=True End With End Sub
Private Sub CommandButton3_Click()
' INSERT PAGE NUMBERS IN THE FORM: Pagina X / Y With Word.Application.ActiveDocument Selection.TypeText Text:="Pagina " Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "PAGE ", PreserveFormatting:=True Selection.TypeText Text:=" / " Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "NUMPAGES ", PreserveFormatting:=True End With End Sub
Private Sub CommandButton4_Click()
' INSERT PAGE NUMBERS IN THE FORM: Pagina X din Y With Word.Application.ActiveDocument Selection.TypeText Text:="Pagina " Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "PAGE ", PreserveFormatting:=True Selection.TypeText Text:=" din " Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "NUMPAGES ", PreserveFormatting:=True End With End Sub
Private Sub CommandButton5_Click() Unload FormPageXofY End Sub |
_______________________________________

|
|
pus acum 5 ani |
|