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
Related
I'm trying to open an excel file in SharePoint through a vba code in another local excel file. However, it gives me a Dialog Box and lets me save the file instead of directly opening in Excel.
Below is the code I used. Would be very grateful for your help. Thanks.
Dim wb AS Workbook
FilePath = "https://company.sharepoint.com/sites/Folder1/Folder2/Filename.xlsm"
Set wb = Workbooks.Open(Filename:=FilePath, UpdateLinks:=0)
I had this issue also. First, you have to fix something in the excel options. So, go to File > Options > Advanced > then scroll down until you see Link Handling > then select the box that says "Open Supported hyperlinks to Office in Office Desktop Apps". Next, I used the coding below to get the link to work. you just need to reply the part of the coding with you sites url sharepoint file. the only issue I came up with is that you have to run the coding below, wait for the file to completely load, and then you can run macros on this file.
Sub OPEN_YRLY()
'
' OPEN_YRLY Macro
'
'
Range("C1").Select
ActiveWorkbook.FollowHyperlink Address:="https://aramark365-my.sharepoint.com/:x:/r/personal/......", NewWindow:=False, AddHistory:=True
End Sub
I have an macro enabled Excel file on a SharePoint that when a user opens it from the SharePoint the file opens programmatically another macro enabled Excel file on the same SharePoint. The file being opened by the vba macro needs to be edited, and must be editable by multiple users at the same time. However I can't get it to even open in edit mode. Using Office 365
I've tried << ActiveWorkbook.LockServerFile >> but always get an error message << Run-time error 1004: Method 'LockServer' of object'_Workbook' failed >>.
The code that I show below is in the Excel file that is opened manually by the user and that opens automatically the other Excel file. The other Excel file when opened works fine (if I remove the LockServerFile command), all it's macro's work fine, but it is open in read only and changes cannot be saved. Again this file should be editable by multiple users simultaneously.
' this code is in the "ThisWorkbook" tab
Sub workbook_open()
Set DB = Workbooks.Open(DBname, 3, False, , , , True)
ActiveWorkbook.LockServerFile ' this is where is crashes
'more code...
End Sub
' Note: DB is declared in a module
Public DB as Workbook
Public Const DBname As String = "https://ledvance365.sharepoint.com ... .xlsm"
Looks like << ActiveWorkbook.LockServerFile >> wasn't working because the SharePoint settings was not on "Open Documents in Client Applications by Default"
But once I got the SharePoint owner to change the SharePoint settings to "Open Documents in Client Applications by Default" the << ActiveWorkbook.LockServerFile >> command worked.
Maybe check out the following link to check if the file is already locked.
https://www.mrexcel.com/forum/excel-questions/906983-vba-support-checking-if-file-locked-sharepoint.html
Also in general it helps if you use your objects when you set them.
Dim DB as Workbook
Set DB = Workbooks.Open(filename:=DBname, editable:=True)
DB.LockServerFile
I had a similar issue. The code crashes at the same point you highlighted.
ActiveWorkbook.LockServerFile
Seems to fail when the document is already editable.
On Error Resume Next
ActiveWorkbook.LockServerFile
Fixes the issue I was experiencing since the code will continue on when the file is already editable and similarly makes a file editable if it wasn't previously.
I'm trying to export an Excel document (all sheets) as HTML. When using the code below I receive no errors and the script runs for several seconds (about 15) but never actually produces any output. I've tried replacing the file name "test.html" with a full path in both HFS and POSIX formats and I still get the same results -- nothing
tell application "Microsoft Excel"
tell active workbook
save as sheets filename "test.html" file format HTML file format -- doesn't seem to actually work
end tell
end tell
If anyone can see my error and/or has successfully gotten this to work in the past, I would love an explanation to my problem.
Thanks in advance.
Both of these worked for me:
tell application "Microsoft Excel"
tell active workbook
save as active sheet filename (POSIX file "...full path here..." as text) file format HTML file format
end tell
end tell
tell application "Microsoft Excel"
tell active workbook
save as active sheet filename "...full path here..." file format HTML file format
end tell
end tell
(Although I would expect it to just export the active sheet, it actually dumps out all of the sheets in the workbook.)
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
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