I'm trying to get an Applescript to open a shared Excel file, but the read only function doesn't seem to work with the open alias syntax, am I doing something wrong?
Code similar to below.
set MasterFile to ""Macintosh HD:Users:myname:Desktop:Test File.xlsb"" as text
tell application "Microsoft Excel"
activate
open alias MasterFile with read only
end tell
Thanks,
VD
You need to open the file, set the read only recommendation, close workbook and open again. Without setting the display alerts you'll get a prompt asking whether to open as read-only.
Cheers!
set MasterFile to "Macintosh HD:Users:usrname:Desktop:Test File.xlsb" as alias
tell application "Microsoft Excel"
set display alerts to false
open MasterFile
set read only recommended of active workbook to true
save workbook
close active workbook
open MasterFile
set display alerts to true
end tell
Related
I have a template that we use at work that I want to edit using visual basic. I have a gui built that asks the user for a few pieces of data. I need to open the template and just edit the contents of the template based on the user input. I have done research so far and everything I've seen shows me how to open a new excel document, not a current one. How do I open the current template?
*I get the user to browse for and select the filename and have that stored as a variable
Hard to say what you want to achieve maybe more clarification is needed.
To reference an Opened Excel file
Set execlObj = GetObject(fileName)
To open an Unopened Excel file (in separate Excel application)
Dim oXLApp As Object, wb As Object
Set oXLApp = CreateObject("Excel.Application")
Set wb = oXLApp.Workbooks.Open(fileName)
Where file name is e.g. c:\test.xls
I have a folder of .xls files of which some are genuine excel files and some are excel xml files (but still with the .xls extension). To work with the files in a separate program, I'm trying to convert them all to a consistent format (Excel 98-2004) and want to use an applescript to do this while retaining the original file names and directory structure.
As of now, I have a working loop and list of files, and am accomplishing everything but the save function:
set file_Name to "/Users/me/path/to/data.xls"
tell application "Microsoft Excel"
activate
open file_Name
save workbook as workbook (active workbook) filename file_Name file format (Excel98to2004 file format) with overwrite
close workbooks
quit
end tell
When I run this code, I get the following replies:
tell application "Microsoft Excel"
activate
open "/Users/drewmcdonald/Desktop/Madhupur_10February2014.xls"
get active workbook
--> active workbook
save workbook as workbook (active workbook) filename "/Users/drewmcdonald/Desktop/test.xlsx"
--> missing value
close every workbook
quit
end tell
The spreadsheets are successfully opening and closing, but the file format is not changing and I don't know what to make of the "missing value" error. Any idea how to get this to work? Thanks!
EDIT: Just noticed that the file format parameter is missing from the reply text, so I'm guessing the problem is in there.
Got it.
I needed to set a workbook name variable to get full name of active workbook before trying to save it. This is because the workbook name that Excel assigns as it opens sheets is somewhat inconsistent. Final code looks like this:
set file_Name to "/Users/me/path/to/data.xls"
tell application "Microsoft Excel"
activate
open file_Name
set wkbk_name to get full name of active workbook
save workbook as workbook wkbk_name filename file_Name file format Excel98to2004 file format with overwrite
close workbooks
quit
end tell
I want to open and save an excel file in sharepoint, which has no excel installed. I tried to write an vbscript but I only can find which called excel application. Please help to advise. Thank you!
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("D:\Roambi\Test excel\Test.xlsx")
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
WScript.Quit
I am not sure about the reason of the issue, but if you need open and modify some content - maybe Open XML SDK could help. However if you need to open to run some script inside that file - you'll need to have installed Excel application
I have an Excel 2008 file. This give a warning message when opened. I would like this message not to be displayed.
tell application "Microsoft Excel"
open workbook workbook file name "private:var:root:Desktop:XLS FILES:Copy of
New Microsoft Excel Worksheet (5).xlsx" read only 1
end tell
With the above script the Excel file is opened but the Excel warning still appears:
Try:
tell application "Microsoft Excel"
open workbook workbook file name "private:var:root:Desktop:XLS FILES:Copy of New Microsoft Excel Worksheet (5).xlsx" with ignore read only recommended
end tell
I have an excel spreadsheet that are being used by multiple users. I saved it as read-only recommend prompt pop-up.
However, when I to use another program to open this file ( to refresh database and save the file ) , I still have to select read-only to 'No' from the prompt pop-up everytime.
How could I temporary enable the read-only prompt pop-up ?
Thank you.
if opening from excel ... this should do it
Application.DisplayAlerts = False
Workbooks.Open ("yourfile.xlsm"
Application.DisplayAlerts = True
if opening from elsewhere, perhaps you could just use a "stub" workbook or xla with the same 3 lines of code to get at yourfile.xlsm. Hope that helps.