Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8256603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:54:28+00:00 2026-06-08T01:54:28+00:00

I have about 400 excel files. I want to insert a column just before

  • 0

I have about 400 excel files. I want to insert a column just before the first column in the existing file and then insert the name of the file into each row of that column.

I know a little bit of Applescript and based on that I wrote this script so that I can drop some files onto the script and it will execute the script on each one of those files.

I was wondering if someone could help me in completing the “TO DO” lines. Upon execution this script gives me dialogue boxes with the path of files that I drop on top. But the excel application throws an error dialogue box which says” Not enough memory”. I tried this with only 2 excel files so it wasn’t the number of files that caused the error.

Can someone please give me a hand with completing the TODO lines and give me an ide as to why Im getting the error. Thanks

property numFiles : 0

on open excelFiles


set fileNames to ""

tell application "Finder"
    repeat with eachFile in excelFiles

        --open document file eachFile

        --tell application "Microsoft Excel"

        --increment count



        --save name of each file

        set fileNames to fileNames & return & (POSIX path of eachFile)

        --TO DO insert a column

        --TO DO insert text in each column to the name of eachFile

        --end tell
    end repeat
    display dialog fileNames
    --display dialog "Ouch that hurt " & return & "You dropped " & (count excelFiles) & "files on me"
end tell
end open

on addFilePath(eachFile)
set fileNames to fileNames & (POSIX path of eachFile)
end addFilePath

Thanks a lot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:54:29+00:00Added an answer on June 8, 2026 at 1:54 am

    I don’t understand everything –> insert the name of the file into each row of that column | TO DO insert text in each column to the name of eachFile.

    Here is the script, Updated :

        on open excelFiles
        set numFiles to count excelFiles
        repeat with eachFile in excelFiles -- open each file in Excel
            tell application "Microsoft Excel"
                set tBook to open workbook workbook file name (eachFile as string)
                set tName to name of tBook
                insert into range column 1 of active sheet -- insert column
    
                set lastCell to last cell of used range of active sheet -- get last cell from the used range
                set value of range ("A1:A" & first row index of lastCell) of active sheet to tName --set first column's values to the file name
    
                close tBook saving yes
            end tell
        end repeat
        display dialog numFiles
    end open
    

    Edit : I forgot the error :

    Not enough memory : This weird error seems to be : you call a handler without using my or tell me to) in a tell block application.

    Use my like this : set x to my addFilePath(eachFile)

    Also, a tell application "Microsoft Excel" block in the application Finder block is not recommended, this can cause unexpected errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a header file with about 400 function declarations and its corresponding source
We have a .aspx file which has about 400 lines of javascript code. Is
I have a table called Names, it contains about 400 inputs. I want for
I got xml file which is about 400 mb. in size. I want to
I have data about 400 rows in columns B through U. Column F is
I have read this article about 400% boost of your website . This is
I have this running software that is currently being used by about 400 people.
i have about 20 possible exception messages that i want thrown when an error
We have an automatic process that opens a template excel file, writes rows of
i have about 400 pages and UserControls in my asp.net website. what is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.