jinhuang1992 has asked for the wisdom of the Perl Monks concerning the following question:

my $excel = Win32::OLE->new('Excel.Application'); my $book = $excel->Workbooks->Open("c:\\temp\\sale.xls"); my $sheet = $book->Worksheets(1); with ($sheet->PageSetup, CenterFooter => "&F")

&F is a code that prints a file name sale.xls.   What is the code to print a full path c:\temp\sale.xls?

Thanks.

janitored by ybiC: Balanced <code> tags around code block, minor format tweaks for legibility

Replies are listed 'Best First'.
Re: Print a full path in center footer
by jmcnamara (Monsignor) on Aug 13, 2004 at 19:12 UTC

    What is the code to print a full path c:\temp\sale.xls

    &Z&F But only in more recent versions of Excel.

    --
    John.

Re: Print a full path in center footer
by GreyGlass (Sexton) on Aug 13, 2004 at 19:34 UTC
    &[Path]&[File] will do what you want.

    Found by Googling: excel XP path footer. Time: 30 seconds.

    Googling or reading Excel docs is a MUCH better way to get answers to this question, as it has nothing to do with Perl.

Re: Add a full path
by davorg (Chancellor) on Aug 13, 2004 at 15:45 UTC

    We're going to need quite a lot more information in order to give any sensible help. What are you trying to do? What modules are you using? Can we see a small sample of code that we can run ourselves?

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      Based on "$sheet", I'm guessing OLE to Excel and also that the answer is really about Excel and that OLE and Perl don't change it at all.

      But I see no documentation for &F nor &[File] in my Excel's help so I think the only hope is some advanced non-standard Excel documentation, perhaps google could find that. (Or one might get lucky just experimenting.)

      - tye        

      my $excel = Win32::OLE->new('Excel.Application'); my $book = $excel->Workbooks->Open("c:\\temp\\sale.xls"); my $sheet = $book->Worksheets(1); with ($sheet->PageSetup, CenterFooter => "&F") &F is a code that prints a file name sale.xls. What is the code to print a full path c:\temp\sale.xls? Thanks.

        Please use <code> tags to make your code easier to look at. And you only need to post your code once!

        I'm not sure how you expected us to work that out from your original description of the problem. But now I know what you are trying to do, I can see that it has nothing to do with Perl.

        So here's what I did. I googled for "Excel &F" to see if I could find a list of these codes. The second link was called "Pathname in headings, footers, and cells" and reading that page seems to indicate that &Z is the answer to your question.

        As a non-Excel user, it took me 30 seconds to find the answer once I knew the question. Surely you can see that Google would have been a better route than PerlMonks?

        --
        <http://www.dave.org.uk>

        "The first rule of Perl club is you do not talk about Perl club."
        -- Chip Salzenberg

Re: Add a full path
by Fletch (Bishop) on Aug 13, 2004 at 15:57 UTC
    use PSI::ESP qw( DWIM ); ## . . . my $full_path = DWIM( "add a full path before a file name", $short_pat +h );