I'm having a run-time error 1004 on closing the excel sheet. Through my research, most of error 1004 happen when the users are trying to copy the sheet by macro or closing the sheet by macro.
In my case, the error appears even when I close the developer tab and create a new excel file. Some resources I found online include the You may receive a "Run-time error 1004" error message when you programmatically set a large array string to a range in Excel 2003 and some other forum posts. However none of them is applicable in my case since I'm trying to close the file by the 'x' button. Please let me know if should describe the question more accurately. Thanks.
Related
I use to use excel vba to send copied ranges from Excel to PowerPoint. After a recent office355 update the technique does not work on the macro anymore. I get error "Run-time error '-2147188160 (80048240)': Shapes (unknown member): Invalid request. Clipboard is empty or contains data which may not be pasted here.
Below is the code portion
Worksheets("slide").Range("A1:E12").Copy
Application.Wait (Now() + TimeValue("00:00:05")
Set ppShape = PpSlide.Shapes.PasteSpecial(DataType:=ppPasteDefault)
Does anyone know any fixes? I need the pasted values to be text, not images. The below code works but its not what i want, cause it is copy picture. I tried all the different data type and most of them did not work.
I know the error is not in the copy line, because when the code breaks, i can manually paste the copied cells on clipboard to the powerpoint. I also know the error is not related to making connection with the PowerPoint because lines like this in the code work.
Worksheets("slide").Range("A1:E12").CopyPicture
Application.Wait (Now() + TimeValue("00:00:05")
Set ppShape = PpSlide.Shapes.PasteSpecial(DataType:=ppPasteDefault)
Note: What makes this more confusing is i tried the code on a different PC with Office 365 Version 2203 (instead of office 2201) and it worked perfectly.
I have some macro code that runs in my BeforeSave event and before it runs I am using the following line.
Application.Interactive = False
When saving the file normally everything works fine. If I select multiple tabs via ctrl/click and try to save I get an error which reads.
Run-time error '1004':
Method 'Interactive' of object '_Application' failed
It seems to me that the Interactive property is not available to set when you have multiple sheets selected. The reason I want to select several sheets and not the entire document is I am doing a save as and selecting PDF.
Any ideas why this would not work or what could be use in place of Application.Interactive?
I'm trying to refresh a query on a cell change, however I can't figure out how to reference the query.
My code: Sheets("Roster Query").QueryTables(0).Refresh
Just errors out with:
Run-time error '1004':
Application-defined or object-defined error
I have a sheet named "Roster Filter" that has query table I want to refresh. How can I get that QueryTable and refresh it?
Edit: Also tried:
For Each qt In Sheets("Roster Query").QueryTables
qt.Refresh
Next
This does not error out, but the query is not refreshed.
Query tables are a relic of older versions of Excel, before tables were a thing. Not sure how to even create one in Excel 2007+.
If you added your QT via the Data/Get External Data Ribbon menu, what you added was actually a ListObject.
I tested this on Sheet1, adding a simple query - Excel created the ListObject for me:
In the immediate pane, I get these results:
?Sheet1.QueryTables.Count
0
?Sheet1.ListObjects.Count
1
And I can reproduce your exact same error:
Sheet1.QueryTables(0).Refresh 'runtime error 1004
The error is simply outrageously misleading, that's all - it should really be an index out of bounds.
The solution is to refresh the ListObject instead:
Sheet1.ListObjects(1).Refresh 'works
You can access the underlying QueryTable object via the ListObject, too:
?Sheet1.ListObjects(1).QueryTable.CommandText 'gives you the query
You're seeing an error because the .Item method is base 1, not base 0
For example, this worked for me in Excel 2016:
Sheets("Roster Query").QueryTables(1).Refresh
So if you only have one QueryTable, it would be .QueryTables(1).
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
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.