Excel scripting

The following “simple” code :

set theWorkbookFile to choose file with prompt “Please select an Excel workbook file:”
set theWorkbookName to name of (info for theWorkbookFile)
tell application “Microsoft Excel”
open theWorkbookFile
make new workbook
set theWorkbook to workbook theWorkbookName
set theWorkbook to active workbook
tell active workbook
make new worksheet at beginning
activate object worksheet “Sheet1”
set value of cell “A1” to “A”
end tell
end tell

Results in the following error:
error “Microsoft Excel got an error: The object you are trying to access does not exist” number -10006 from value of cell “A1” of active workbook

Please help

I never use Merdosoft products but it seems that your error is easy to find.

set theWorkbookFile to choose file with prompt "Please select an Excel workbook file:"
set theWorkbookName to name of (info for theWorkbookFile)
tell application "Microsoft Excel"
    open theWorkbookFile
    make new workbook
    set theWorkbook to workbook theWorkbookName
    set theWorkbook to active workbook
    tell active workbook
        make new worksheet at beginning
        activate object worksheet "Sheet1"
tell worksheet "Sheet1" # ADDED
        set value of cell "A1" to "A"
end tell # ADDED
    end tell
end tell

Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) mercredi 12 avril 2017 15:14:03

I like the way “Merdosoft” works out in French better than the standard English “Micro$oft.”

Microsof Office is a bargain compared to the immature/incomplete iWork bundle from Apple. iWork is nice for candy land users but is completely lost at professional level.

I do rely on Excel. Google Sheets is getting competitively extensible, but it’s still not there yet.

I’ve barely used iWork.

But most people’s problems with Microsoft are due to their business practices foremost, and their software quality second. Not with the feature set of Office.