To remove the validation request, comment (apostrophe at the beginning of the line) the following lines (in bold underline):
Edit: Edit the lines in bold as said before:
If GetAttr(PathName) And vbReadOnly Then If the file is read-only ret = MsgBox("This file is read-only, do you want to write to it?" & vbNewLine_ & vbNewLine & "Remember to save your changes later", vbYesNo, title) 'message to ask if we want to access it in read and write If ret = vbNo Then Exit Sub 'If not, we leave the programme SetAttr PathName, vbNormal 'If so, we remove the read-only in Windows Part.FileReload ret = Part.ReloadOrReplace(False, Part.GetPathName, True) Part.FileReload 'We reload the document in SolidWorks Else 'Otherwise (= file read, write) ret = MsgBox("This file is read-write, do you want to make it read-only?", vbYesNo, title) 'Message to ask if you want to access it in read-only mode If ret = vbNo Then Exit Sub 'If not, we leave the programme SetAttr PathName, vbReadOnly 'If so, we put read-only in Windows Part.FileReload ret = Part.ReloadOrReplace(False, Part.GetPathName, True) Part.FileReload 'We reload the document in SolidWorks End If End Sub
Re: Modified as before, the macro writes read-only files and read-only writes to write files.
To have only the write, modify the end of your macro with this one:
If GetAttr(PathName) And vbReadOnly Then If the file is read-only 'ret = MsgBox("This file is read-only, do you want to write to it?" & vbNewLine_ & vbNewLine & "Remember to save your changes later", vbYesNo, title) 'message to ask if we want to access it in read and write 'If ret = vbNo Then Exit Sub 'If not, we leave the programme SetAttr PathName, vbNormal 'If so, we remove the read-only in Windows Part.FileReload ret = Part.ReloadOrReplace(False, Part.GetPathName, True) Part.FileReload 'We reload the document in SolidWorks Else End If End Sub