• 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: Excel: Append to Range
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Excel: Append to Range


  • Subject: Re: Excel: Append to Range
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 27 Mar 2015 08:13:54 -0500

On Mar 26, 2015, at 18:20, Christopher Stone <email@hidden> wrote:
So this is now working like a champ in Microsoft Excel 14.4.8 on OSX 10.9.5.
______________________________________________________________________

Hey Folks,

This version appends file name and modification date to columns A & B of the active worksheet.

I'm writing this for someone who wants to collate these statistics for new files added periodically to a folder.

--
Best Regards,
Chris

-------------------------------------------------------------------------------------------
set watchFolder to alias ((path to home folder as text) & "test_directory:Watch_Folder_Test:")
set excelList to {}
set fileNameList to {}
set modDateList to {}

# Retrieve Name & Modification Date of the files in the watch folder.
tell application "Finder"
  set fileAliasList to (files of watchFolder whose label index is not 6) as alias list
  if fileAliasList = {} then error "No new files!"
  set AppleScript's text item delimiters to " "
  repeat with i in fileAliasList
    set end of fileNameList to name of i
    set end of modDateList to (get {short date string, time string} of (get modification date of i)) as text
    set label index of i to 6
  end repeat
end tell

# Convert the list of items to a list of lists.
repeat with i from 1 to (length of fileNameList)
  set end of excelList to {item i of fileNameList, item i of modDateList}
end repeat

# Append data to columns A & B of the active worksheet.
tell application "Microsoft Excel"
  tell active sheet of active workbook
    set lastFilledCell to get end (range "A65536") direction toward the top
    if value of lastFilledCell = "" then
      set firstBlankCell to lastFilledCell
    else
      set firstBlankCell to get offset lastFilledCell row offset 1
    end if
    set cellAdrsLocal to get address local firstBlankCell
    set AppleScript's text item delimiters to "$"
    set lastRow to last text item of cellAdrsLocal
    set newRange to cellAdrsLocal & ":$B$" & (lastRow + (length of fileNameList) - 1)
    set value of range newRange to excelList
  end tell
end tell
-------------------------------------------------------------------------------------------

 _______________________________________________
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: 
 >Excel: Append to Range (From: Christopher Stone <email@hidden>)
 >Re: Excel: Append to Range (From: Shane Stanley <email@hidden>)
 >Re: Excel: Append to Range (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Best way to script Excel 2016 from Python
  • Next by Date: Microsoft Outlook 2011 - Changing Subject field
  • Previous by thread: Re: Excel: Append to Range
  • Next by thread: Re: Excel: Append to Range
  • Index(es):
    • Date
    • Thread