Wanted: Filename Macro
Wanted: Filename Macro
Hi,
I am contemplating making the move from Word to Nisus Writer Express. One function that I would really need is to be able to put the filename, the pagenumber & the total number of pages of the document into the footnote section. I can do this manually in 3 steps but I was wondering if there is a Macro to do this with one click.
Thanks
I am contemplating making the move from Word to Nisus Writer Express. One function that I would really need is to be able to put the filename, the pagenumber & the total number of pages of the document into the footnote section. I can do this manually in 3 steps but I was wondering if there is a Macro to do this with one click.
Thanks
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
This should do it:
Note that the file name is not automatically updating, so if you rename your file you'll have to run the macro again (or edit the header/footer).
Code: Select all
$name = Document Property "File Name Without Extension"
Type Text "$name, page "
Menu ":Insert:Automatic Number:Page Number"
Type Text " of "
Menu ":Insert:Automatic Number:Pages in Document"
Hi Martin,
Many thanks for the quick reply. Unfortunately I get the folowing compilation error:
"Semicolon seems to be missing at /tmp/NisusScript line 8.
Semicolon seems to be missing at /tmp/NisusScript line 9.
String found where operator expected at /tmp/NisusScript line 10, near "Menu ":Insert:Automatic Number:Page Number""
(Do you need to predeclare Menu?)
Semicolon seems to be missing at /tmp/NisusScript line 10.
Semicolon seems to be missing at /tmp/NisusScript line 11.
String found where operator expected at /tmp/NisusScript line 12, near "Menu ":Insert:Automatic Number:Pages in Document""
(Do you need to predeclare Menu?)
syntax error at /tmp/NisusScript line 9, near "Type Text "
Execution of /tmp/NisusScript aborted due to compilation errors."
Any ideas?
Thank you
Many thanks for the quick reply. Unfortunately I get the folowing compilation error:
"Semicolon seems to be missing at /tmp/NisusScript line 8.
Semicolon seems to be missing at /tmp/NisusScript line 9.
String found where operator expected at /tmp/NisusScript line 10, near "Menu ":Insert:Automatic Number:Page Number""
(Do you need to predeclare Menu?)
Semicolon seems to be missing at /tmp/NisusScript line 10.
Semicolon seems to be missing at /tmp/NisusScript line 11.
String found where operator expected at /tmp/NisusScript line 12, near "Menu ":Insert:Automatic Number:Pages in Document""
(Do you need to predeclare Menu?)
syntax error at /tmp/NisusScript line 9, near "Type Text "
Execution of /tmp/NisusScript aborted due to compilation errors."
Any ideas?
Thank you
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
My apologies, that macro will only function in Nisus Writer Pro. I should have been more observant with regard to your initial post.
I'm sorry to say there's no single macro that can accomplish what you desire in Express. This is probably the closest:
I'm sorry to say there's no single macro that can accomplish what you desire in Express. This is probably the closest:
Code: Select all
#Nisus Macro Block
#source front selection
#destination front selection
#After Execution
#Insert:Automatic Number:Page Number
#End Nisus Macro Block
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
$path = $ARGV[1];
$path =~ /\/([^\/]+?)(\.\w+?)?$/;
$name = $1;
print "$name, page ";
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
I thought about it and there is a solution for you. Save the following as a macro called "Insert Total Pages":
And then you can make use of this single macro to do what you desire:
Code: Select all
#Nisus Macro Block
#source front selection
#destination front selection
#After Execution
#Insert:Automatic Number:Pages in Section
#End Nisus Macro Block
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
print " of ";
Code: Select all
#Nisus Macro Block
#source front selection
#destination front selection
#After Execution
#Insert:Automatic Number:Page Number
#Macro:Insert Total Pages
#End Nisus Macro Block
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
$path = $ARGV[1];
$path =~ /\/([^\/]+?)(\.\w+?)?$/;
$name = $1;
print "$name, page ";
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
I've thought about this some and this macro should do exactly what you wanted and does not make use of any menu commands, so it will work in the German localization no problem:
Code: Select all
#Nisus Macro Block
#source front selection
#destination front selection
#Send Text as RTF
#End Nisus Macro Block
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
$path = $ARGV[1];
$path =~ /\/([^\/]+?)(\.\w+?)?$/;
$name = $1;
$rtf = '{\rtf1 \mac{' . $name . ', page {\field {\*\fldinst {PAGE}}} of {\field {\*\fldinst {NUMPAGES}}}}}';
print $rtf;