Open an Excel file in exclusive mode using VBScript
<p>I have a simple question, but I've searched for this and couldn't find any helpful topics..</p>

<p>I'm working on a VBScript that opens an Excel file and modify a few stuff in it.. so I'm using this code:</p>

<pre><code>    Set objXLApp = CreateObject("Excel.Application")

    objXLApp.Visible = False
    objXLApp.DisplayAlerts = False

    Set objXLWb = objXLApp.Workbooks.Open(FilePath)
</code></pre>

<p>Now, what I want to do is to open the Excel file using a way that locks the file and prevents the user from opening it while it's open by the script (until it's closed).</p>

<p><strong>Update:</strong></p>

<p>I think the problem is somehow related to the Excel instances, I tried to do the following (while the file is open by the script):</p>

<ul>
<li>When I <strong>manually</strong> open the file (while it's open by the script) they're both become a single instance.</li>
<li>When I open any other Excel file they're both <strong>also</strong> become a single instance!!! And the original file (opened by the script) becomes visible!</li>
</ul>

<p>Now this is weird because I'm using <code>CreateObject("Excel.Application")</code> and not <code>GetObject(, "Excel.Application")</code></p>