Note that there are some explanatory texts on larger screens.

plurals
  1. POExcel Removed Attachments when trying to Dynamically Create a new Module
    primarykey
    data
    text
    <p>I have this little VBA module that I call from one workbook to update all Excel Workbooks in a given folder. By update I mean it copies a module called GetActiveXControlValues and then runs this macro on each workbook in that folder. Now when I run this on my machine everything works fine. When my co-worker runs this same code with the same files, they gets a surprise after copying the module. When you go to look at the workbook that should have the new module called 'GetActiveXControlValues', instead there is no module by that name, instead it is called 'Module1'. In addition, when you look inside the new module it says 'Attachment has been removed' in red. I checked and my co-worker has the exact same Security Settings in Excel 2010 as I have.</p> <p>I have enable all Macros and Trust VBA Project Object Model. I have Prompt me for enabling all ActiveX controls. I have Disable Trusted Documents unchecked and all the boxes on the Protected View tab. Anyone seen this before or have an idea what I can try to troubleshoot? </p> <h2>Sample Code:</h2> <pre><code>Sub CopyModuleAndExecuteIt() Dim wb As Workbook Dim sFile As String Dim sPath As String Dim sFullMacroName As String SetFolder sPath = sExcelFolder ChDir sPath sFile = Dir("*.xls") ' File Naming Convention Do While sFile &lt;&gt; "" ' Start of LOOP ' Open each Excel File in the specified folder Set wb = Workbooks.Open(sPath &amp; "\" &amp; sFile) ' SET BP HERE! Sleep (1000) ' Unprotect the Documents using SendKeys Hack UnprotectVBADocument ' Import the GetActiveXControlValues Module into the Workbook wb.VBProject.VBComponents.Import ("D:\GetActiveXControlValues.bas") ' SET BP HERE! sFullMacroName = "'" &amp; wb.Name &amp; "'" &amp; "!" &amp; wb.VBProject.VBComponents.Item("GetActiveXControlValues").Name &amp; ".GetActiveXControlValues" ' Run the GetActiveXControlValues Macro Application.Run (sFullMacroName) ' Close the Workbook Saving Changes wb.Close True sFile = Dir Loop ' End of LOOP End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload