• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Saving an Excel worksheet as a .pdf file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving an Excel worksheet as a .pdf file


  • Subject: Re: Saving an Excel worksheet as a .pdf file
  • From: Lists <email@hidden>
  • Date: Tue, 16 Dec 2014 16:04:19 -0800

This should work as a D&D applet. I haven’t used it in a while, but I’m pretty sure it worked in Office 11 as well as 08.

(* Drag and drop conversion (duplication) of Microsoft Excel files to PDF files using Excel 2008. *)

on open fillist
set bs to "/"
set d to "-"
tell application "Finder"
set defLoc to container of (item 1 of fillist) as alias
end tell
set destn to choose folder with prompt "You are converting (duplicating) Excel files to PDF files" & return & "Select a location to save converted files." default location defLoc
repeat with lvar in fillist
tell application "Finder"
set thename to name of lvar
set filex to name extension of lvar
set l to length of filex
end tell
set nuname to text 1 thru text item -(l + 1) of thename
if "/" is in nuname then
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to bs
set txtLst to every text item of nuname as list
set AppleScript's text item delimiters to d
set nuname to txtLst as string
set AppleScript's text item delimiters to oldDelims
end if
set filname to (destn as string) & nuname & "pdf"
tell application "Microsoft Excel"
launch
open lvar
save as active sheet filename filname file format PDF file format
close window 1 saving no
end tell
end repeat
end open

HTH
J


On Dec 16, 2014, at 1:52 PM, Bill Guion <email@hidden> wrote:

I'm trying to create and save an Excel worksheet as a .pdf file. The script below is my current attempt. I have removed all of the Excel manipulation portion of the script to help focus on the file save portion. The manipulation portion works just fine. The script starts by prompting me for a csv file. The display dialogs all show the values I expect for the various values. The script runs without error, but no file is saved. I would really appreciate someone pointing out my errors.

-- find the csv file
set myLifeList to choose file with prompt "Locate Bill's Life List"

-- define folder to save .pdf into
set pdfSavePath to "/Macintosh HD:Documents:pdfs:" as string

tell application "Microsoft Excel"
activate
open myLifeList
end tell

SNIP

tell application "Microsoft Excel"
copy value of cell "N2" to filename
display dialog "filename is " & filename
display dialog "pdfSavePath is " & pdfSavePath
set fullName to pdfSavePath & filename & ".pdf"
display dialog fullName
try
save active sheet in fullName as PDF file format
end try
end tell


Thanks in advance.

    -----===== Bill =====-----

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Saving an Excel worksheet as a .pdf file (From: Bill Guion <email@hidden>)

  • Prev by Date: Re: is delay broken in JSA
  • Next by Date: Re: Javascript for automation quastions
  • Previous by thread: Re: Saving an Excel worksheet as a .pdf file
  • Next by thread: OSAScriptController's stopScript action
  • Index(es):
    • Date
    • Thread