9/10/2023 0 Comments Read only macro in c![]() SetAttr backupfolder & "Open Machine Schedule - Current. ThisWorkbook.SaveAs Filename:=backupfolder & "Open Machine Schedule - Current.xlsx", FileFormat:=xlOpenXMLWorkbookįormattime = Format(savetime, "hh.MM.ss")įormatdate = Format(savedate, "DD - MM - YYYY")ĪctiveWorkbook.SaveAs backupfolder & "Open Machine Schedule - Current.xlsx", FileFormat:=xlOpenXMLWorkbook ![]() Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)īackupfolder = "C:\Users\" & Environ("username") & "\Documents\Dropbox\Systems\Open Machine Schedule\" Here is the code that prompted this question: Option Explicit I don't get this error when the copied workbook is closed, it overwrites it like it's supposed to. When I run the macro below and have the copied read-only workbook opened prior, I get an error:"vba run time error 1004 cannot access read-only document" What started the prompt for using this bit of code(above) was because I wanted the macro to not cause an error if the read-only workbook was opened by another user. MsgBox "File is Open!" 'Never get this to display when I have the excel file open VBA Open Workbook as Read Only in Excel Sub VBAOpenWorkbookAsReadOnly () Variable declaration Dim sFileName As String sFileName 'D:VBAF1VBA Functions.xlsm' Workbooks.Open Filename:sFileName, ReadOnly:True End Sub. Set wBook = Workbooks("C:\Users\" & Environ("username") & "\Documents\Dropbox\Systems\Open Machine Schedule\Open Machine Schedule.xlsx") It will open Workbook as read only from the specified location. xlsx" file is opened or not in vba? Sub Test_If_File_Is_Open_2() How can I check whether or not a "read-only. ![]() I tried this something like this bit of code, but had no luck, it just kept saying "File not open!" even when I had it opened. I would like to be able to overwrite the read-only workbook if it's opened as read-only by another user. In my code I have it copy after closing/saving the workbook. I cannot seem to get a definite feedback on whether or not a read-only workbook is opened or not. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |