Excel Macro - Windows().Activate not taking value <p>The code that works is the following:</p> <pre><code>Windows("Contract Drilldown (3).xls").Activate </code></pre> <p>When I use :</p> <pre><code> Windows(Chr(34) &amp; ddlOpenWorkbooks.Value &amp; Chr(34)).Activate </code></pre> <p>I get:</p> <blockquote> <p>Runtime Error '424': Object Required</p> </blockquote> <hr> <p>If I use a String Variable to pass in the values i.e.:</p> <pre><code>Dim wbn As String wbn = "Contract Drilldown (3).xls" Windows(Chr(34) &amp; wbn &amp; Chr(34)).Activate </code></pre> <p>I get:</p> <blockquote> <p>Run-time error '9': Subscript out of range</p> </blockquote> <hr> <p>And if I use</p> <pre><code>wbn = ddlOpenWorkbooks.Value Windows(Chr(34) &amp; wbn &amp; Chr(34)).Activate </code></pre> <p>I also get </p> <blockquote> <p>Runtime Error '424': Object Required</p> </blockquote> <hr> <p>Anyone have any idea how I can pass in the <em>ddlOpenWorkbooks.Value</em> in without getting an error?</p> <h2>Edit - More Info</h2> <p>Ok so the application looks like this: <img src="https://i.stack.imgur.com/FiAhi.png" alt="enter image description here"></p> <p>the full code block for the Import Data Button is:</p> <pre><code>Public Sub Data_Import() Windows(ddlOpenWorkBooks.Value).Activate Columns("A:V").Select Selection.Copy Omni_Data.Activate Range("A1").Select ActiveSheet.Paste Omni_Data.Range("A:Z").Interior.ColorIndex = 0 Omni_Data.Range("A:Z").Font.Name = "Segoe UI" Omni_Data.Range("A:Z").Font.Name = "Segoe UI" 'Setting Background Colour to white and changing font End Sub </code></pre> <p>The above Sub is called on Click Event for the button.</p> <p>As a test the close button has the following code:</p> <pre><code>Private Sub cmdCancel_Click() MsgBox (ddlOpenWorkbooks.Value) End End Sub </code></pre> <p>Which works fine:</p> <p><img src="https://i.stack.imgur.com/hHtYv.png" alt="enter image description here"></p> <h2>Update</h2> <p>So we have found the problem.</p> <p>As this is being called from a module it didn't know where ddlOpenWorkbooks was and where to pull that data from. </p> <p>The corrected code in the Sub is:</p> <pre><code>Public Sub Data_Import() Windows(frmOmniDataManipulation.ddlOpenWorkbooks.Value).Activate Columns("A:V").Select Selection.Copy Omni_Data.Activate Range("A1").Select ActiveSheet.Paste Omni_Data.Range("A:Z").Interior.ColorIndex = 0 Omni_Data.Range("A:Z").Font.Name = "Segoe UI" Omni_Data.Range("A:Z").Font.Name = "Segoe UI" 'Setting Background Colour to white and changing font End Sub </code></pre> <p>This will allow me to call the sub.</p> <p>Thanks All!</p>