Print Finder 'Get Info'

D

dsk

Can
Finder > Get Info > "Name & Extension"
be printed on an excel worksheet?

Thank you,
David
 
B

Bernard Rey

Can
Finder > Get Info > "Name & Extension"
be printed on an excel worksheet?

Well you can copy and paste it, but I suppose that's not what you're
expecting <g>

If it's an Excel filename you want to have, you can get it with the CELL
function. Type something like:

=CELL("filename",A2)

And it will display the complete filename (and path), prvided the workbook
has already been saved...

If you really want the name only, you can type this (thanks Laurent Longre):

=MID(CELL("filename",A1),FIND("[",CELL("filename",A1))+1,SUM(FIND({"[","]"}
,CELL("filename",A1))*{-1,1})-1)

(all in one cell/line, of course)

If it's the name and extension from any other file, I guess you'll have to
perform it with an AppleScript.
 
J

joec

Not sure what info you want to print but if it's just the worksheet
name and extension that you want to print on the worksheet, then go to
File, Page Set-up, select Headers/Footers, and in the Header or Footer
section click on the drop box and select the worksheet name.

JoeC
 
J

JE McGimpsey

Bernard Rey said:
Well you can copy and paste it, but I suppose that's not what you're
expecting <g>

If it's an Excel filename you want to have, you can get it with the CELL
function. Type something like:

=CELL("filename",A2)

And it will display the complete filename (and path), prvided the workbook
has already been saved...

If you really want the name only, you can type this (thanks Laurent Longre):

=MID(CELL("filename",A1),FIND("[",CELL("filename",A1))+1,SUM(FIND({"[","]"}
,CELL("filename",A1))*{-1,1})-1)

(all in one cell/line, of course)

Note that the file must be saved before CELL("filename",A1) will return
the name and path - otherwise it will return a blank (which will make
Laurent's formula return, for some odd reason, an obviously incorrect
circular reference error).

There are other methods/permutations at

http://www.mcgimpsey.com/excel/formulae/cell_function.html
 
D

dsk

Thank you for your reply. The info you gave does return the file name
up to the 32 characters. I would like to have the entire file name
greater than 32 characters print on my work sheet and if possible in
the header. The "Name & Extension" is shown correctly in "Get Info"
(Finder).
Thank you.
 
B

Bernard Rey

(e-mail address removed) a écrit :
Thank you for your reply. The info you gave does return the file name
up to the 32 characters. I would like to have the entire file name
greater than 32 characters print on my work sheet and if possible in
the header. The "Name & Extension" is shown correctly in "Get Info"
(Finder).

Which version of Excel are you running? As far as I can see, things work
fine up to names over 50 characters in Excel 2004. But it won't with earlier
versions (due to the old Mac OS 9 limitations).
 
D

dsk

Excel X for Mac® service release 1.
PS. 32 characters is limit when I save. If I then change the file name
in the finder to > 32 characters, the titlebar in the Excel spreadsheet
truncates the file name to 32 characters with garbage characters at the
end. I would like to print the file name (> 32 characters) in the
header of the spreadsheet.
Thank you
 
J

JE McGimpsey

Excel X for Mac® service release 1.
PS. 32 characters is limit when I save. If I then change the file name
in the finder to > 32 characters, the titlebar in the Excel spreadsheet
truncates the file name to 32 characters with garbage characters at the
end. I would like to print the file name (> 32 characters) in the
header of the spreadsheet.
Thank you

Can't do it with XLv.X. Office v.X uses the OSX I/O routines that are
limited to 32 characters. XLv.X doesn't know what the actual file-name
is - it gets handed a file handle with the truncated/hashed file name,
by the OS. The name is preserved when saving because only the file
handle is used, but AFAIK there's no way to recover the real name from
within Office.
 
B

Bernard Rey

(e-mail address removed) a écrit :
Excel X for Mac® service release 1.
PS. 32 characters is limit when I save. If I then change the file name
in the finder to > 32 characters, the titlebar in the Excel spreadsheet
truncates the file name to 32 characters with garbage characters at the
end. I would like to print the file name (> 32 characters) in the
header of the spreadsheet.

Here is a workaround that should do the trick:

In the "ThisWorkbook" code page, paste these lines:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
MyFolder = ActiveWorkbook.Path
TheString = "tell application ""Finder"" " & vbCr & _
"get name of every file in folder """ & _
MyFolder & """" & vbCr & "end tell"
MyName = MacScript(TheString)
ActiveSheet.PageSetup.CenterHeader = MyName
End Sub

The workbook has to be the only file in its folder. If there are several
files, it will print the list of files. Or you'll have to trim the list...

If you're not familiar with the Visual Basic Editor, post back, or have a
look at JE McGimpsey's page:

http://www.mcgimpsey.com/excel/modules.html
 
D

dsk

Thank you for your reply. When I click on print a "Compile error:
Syntax error" shows up on my screen. I appreciate your assistance.
David Kramer
 
B

Bernard Rey

(e-mail address removed) a écrit :
Thank you for your reply. When I click on print a "Compile error:
Syntax error" shows up on my screen.

The good point is that this tends to indicate you have found the right place
to paste the macro, as it tries to run when printing (preview should give
the same result, in case you need to do some testing)

As to the compile error, this means something is not correct in the macro.
It sometimes happens, when copying and pasting macro lines from an email
that unwanted (and invisible) additional characters interfer and break the
code. Usually, the concerned lines show up in red. Is it the case? If it is,
try cleaning the beginning of the lines (the two lines that are "indented" -
starting a bit further on the right - often show that kind of problem). Just
delete everything on the left and see if it is enough.

I'll send you (directly) a Workbook with the macro, let's see if it runs
that way (it does run here with Excel v.X / Tiger, so there should be no
reason why it won't in your case)...
 
D

dsk

It works just like you say. I appreciate your assistance very much.
Thank you and have a great year.
David Kramer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top