Excel Macro opens with run time error 32809 - vba

I have an Excel Macro Enabled workbook that I created on Excel 2013. The workbook's macros work well with my computer but does not work on some other computers even if they are using Excel 2013. Works on 7/10 computers I tried both on windows 7 and 8. When I send it to someone's computer that does not work this is what happens:
They open the workbook and once the user clicks "enable content" the workbook errors out "run time error '32809': Application-defined or object-defined error"
debug shows it getting stuck on 2nd line of code below:
private sub workbook open()
Worksheets(1).OLEObjects("ComboBox21").ListFillRange = "impacts"
**Worksheets(2).OLEObjects("ComboBox21").ListFillRange = "yesnoo"** This line errors
if I comment out these two lines, the workbook will open but the combobox21 on worksheet(2) gets renamed to combobox22 and does not work but the first combobox on worksheet(1) loads and functions fine.
I would like to add that if I comment out the lines
Worksheets(1).OLEObjects("ComboBox21").ListFillRange = "impacts"
Worksheets(2).OLEObjects("ComboBox21").ListFillRange = "yesnoo"
I get the error now that "Can't exit design mode because control ' dattimepicker21' cannot be created

I found and fixed the problem, the machines that were not working were missing MSCOMCT2.OCX
http://answers.microsoft.com/en-us/office/forum/office_2013_release-excel/date-picker-dropdown-in-excel-2013/71decdcd-6cc6-4a70-b1ab-20294a2a315a

Related

VBA Excel macro stopped seeing textbox

I have a VBA macro in excel that used to work fine for a few days but today when I launch it's not working anymore. Funny thing is that no changes were made to the excel file nor the macro.
The macro is attached to a button and gets data from a TextBox named CSVExportRange. When I try to launch it I get an
"Object doesn't support this property or method"
error in the line where I set Range based on value of the textfield:
Dim r As Range
Set r = Range(Application.ActiveSheet.CSVExportRange.Value)
I tried experimenting with it and it turns out it doesn't see the TextBox at all now:
Dim a As Worksheet
Dim k As TextBox
Set a = Application.ActiveSheet
Set k = Application.ActiveSheet.CSVExportRange
In the above case debug breaks at the last line with "Object doesn't support this property or method" error.
I have the TextBox setup properly and didn't change it since last time everything worked fine.
What's wrong?
No idea why it happened but restarting Excel twice helped...
Like, when I closed all Excel files and relaunched it, it was not working still. After doing so once more it started working again.
Note that neither is a remote / network / shared file so it's not a case of someone / something else locking some file...

Run-Time error '32809': Application-defined or object-defined error

All,
I just upgraded to Excel 2013 and am running into a strange issue. I have a macro-enabled workbook that has worked successfully for quite some time now. I was updating some of the code and came across this error (32809) when trying to write to a specific sheet. In troubleshooting, I tried this.
Sheets("Summary").Range("G8").Value = "Test"
This resulted in the same error. Then I tried this.
Debug.Print ActiveSheet.Name
Same error. So I selected another sheet on the workbook and debug.print on the name. Worked fine.
Then I tried this.
Debug.Print Sheets(2).Name (This is the sheet number of the problemic sheet)
Same error. It seems to me that there is some form of corruption with this sheet but I am reticent about deleting and recreating. Any suggestions?
Thanks!
While it wasn't a perfect solution, here is how I finally resolved it. I had a user that was still on Excel 2010 make a copy the corrupt sheet within the same workbook, delete the corrupt sheet, then rename the new sheet to the original name. I was then able to use the workbook in Excel 2013 without issue.
I have a Workbook Open Macro which counts the number of rows in a table on opening so that I can summarize how many records were added or deleted during the data entry session:
Private Sub Workbook_Open()
Dim TotalRows As Integer
TotalRows = Worksheets("Data").ListObjects(1).ListRows.Count
If Range("LastRecordOnStart") <> TotalRows Then Range("LastRecordOnStart") = TotalRows
' Stop
End Sub
I started getting the run-time error '32809' with the following line in the code above highlighted in the debugger every time I opened the workbook...
TotalRows = Worksheets("Data").ListObjects(1).ListRows.Count
Rebooting or opening the workbook on another PC still would not fix it. Even opening a previously saved working copy would give the same error - strange. Note:
While coding, I will periodically save the workbook and use windows explorer to copy a snapshot of the workbook where it creates myworkbook copy(1).xlsm, copy(2).xlsm, etc and if I get a corrupted workbook, I rename it myworkbook.bad.xlsm and rename the latest saved working version (e.g myworkbook copy(6).xlsm to MyWorkbook.xlsm with minimal loss.
When this run-time error occurs though, I've had to rebuild the book several times. It only appears to happen when the workbook crashes after a long session of debugging new code with the Userform open and I have to close excel from the Task Manager.
I read the posts here today and was convinced that it was page related when I could list the listrows count on another sheet and if I converted the Listobject on the "Data" worksheet back to a range and recreated the table, I'd still get the run-time error. To cut a long story short, I tried the following:
Open the workbook
When the error popped up, clicked debug
Right clicked on the "End Sub" line of the WorkBook_Open sub and clicked "Set Next statement"
Pressed F5 to allow the code to finish executing
Saved the workbook and it all works now!
I had another crash with the subsequent run-time error and repeated the steps above and it worked a charm again.

A private subroutine in VBA is being activated by other workbooks -- Why?

I have a private subroutine in Workbook A that is running any time I open or close and save other unrelated workbooks. I'm trying to understand why that occurs so I can capture all potential errors that may occur.
The subroutine is an ActiveX ComboBox named TabProg that is supposed to run when the value is changed. I have currently added in a check to see if the active sheet trying to run the code is the "Program Loading" sheet to try and divert any potential errors. See snippet below.
Private Sub TabProg_Change()
MsgBox "Whomp!", vbOKOnly + vbExclamation
If ActiveSheet.Name <> "Program Loading" Then 'do nothing
Else
'Run desired actions on "Program Loading" sheet
End If
End Sub
Any known reasons why this is occurring or other ways to catch it would be helpful. Thanks!
Edit 1: I do not see this problem occur when I open other workbooks in new instances of Excel.
Edit 2: I have modified the code to include a message box whenever the code tries to run, now shown above. It is occurring every time I open or close and save any Excel file, including the file itself. The drop down list in the ActiveX ComboBox is a list of names that correspond to 10 sheets within Workbook A. If I delete the sheet that ComboBox is currently set to, the error will disappear. If I change the ComboBox to a different sheet, the error will reappear.
From what you've wrote in your question, I don't think that your problem can be replicated. I think that your Excel file got corrupted. I had an experience like this: had a file for experimenting with macros, one of the macros used Excel Speech object to say "This is a test file" on opening that particular file. The macro was (as all other macros from this file) not part of my PERSONAL workbook, it was assigned to ThisWorkbook in the bespoke file. At some point a funny thing happened: this "This is a test file" private subroutine got activated every time I opened any Excel file. I did not find any solutions, I just deleted the file where the subroutine was stored. This resolved the problem, but I have no explanation for this. I am afraid the same thing may apply to your file, but maybe other folks have a better idea... maybe it's something in the system registry??? I don't know. Can you manually copy elements / code from this file to a newly created file and just delete the original?

error when trying to execute a macro in one workbook from another workbook

I have a multitude of reports I refresh and publish each day, and I'm trying to write a macro in a separate spreadsheet that will open each of these reports, and run the 'Refresh' macro in each workbook, then close the workbook. Here is the code I have so far:
Sub Reports()
'
' Reports Macro
'
Application.Workbooks.Open ("C:\Users\mmarsh\Documents\Daily Reports\Daily Report.xlsm")
Applicion.Run ("'Daily Report.xlsm'!Refresh")
Workbooks("'Daily Report.xlsm'").Close
'
End Sub
When I execute, the code breaks at the Application.Run line and I get the following error:
Run-time error '424': Object Required.
I'm obviously missing something in the code, and I've read several different resources but have not found a solution. Any assistance would be appreciated!
I'm running Office 2010 x64 on Windows 7 x64.
Check your spelling
Applicion.Run
vs
Application.Run

Excel error when saving as XML spreadsheet

I encountered a strange error in an Excel 2007 add-in that seems to be reproducible with a few lines of macro code (Update: even without code, see below).
Open a new workbook and add the following code to the first worksheet.
Private Sub Worksheet_Change(ByVal Target As Range)
Application.DisplayAlerts = False ' Suppress macro and overwrite warnings
ActiveWorkbook.SaveAs "test.xml", XlFileFormat.xlXMLSpreadsheet
End Sub
Now each change will save the workbook as an XML spreadsheet file.
However, when I open a second instance of Excel and copy a single cell from there to the auto-saving workbook Excel 2007 crashes. (I have also seen an RPC_E_SERVERFAULT error in a comparable situation.) In Excel 2010 the file is saved as expected.
Any ideas what might be the root cause for this behaviour and how to avoid it?
UPDATE
Seems like it's even worse: If I copy data from one Excel (2007) instance to another and save the target workbook as XML spreadsheet Excel crashes. I tried this on two machines, so is this a known bug?