Outlook Vba Code gives an error 1004

2019-07-29 12:35发布

Set wks = wkb.Worksheets("Calendar") 'active worksheet
    wks.Cells(NextRow, 1) = ComboBox1.Value

I have this two lines of code with me. Here it gives me an error number 1004 when I am going to assign the value of combobox to the worksheet's(wks) first cell. Let me know some resolution....

Advance Thanks....

2条回答
来,给爷笑一个
2楼-- · 2019-07-29 12:43

Runtime Error 1004 usually means that you are referring to an object that does not exist in your workbook.

As in your case wks.Cells(NextRow, 1) = ComboBox1.Value check the value of variable NextRow and make sure its greater than 0 to avoid the issue.

Also check wks workbook is valid workbook object.

enter image description here

查看更多
乱世女痞
3楼-- · 2019-07-29 13:06

This issue may occur if either of the following conditions is true:

  • The Microsoft Visual Basic for Applications (VBA) macro copies and pastes one whole row in an Excel 2003 workbook.
  • The Microsoft VBA macro copies and pastes a range of 2,516 rows or more rows in an Excel 2003 workbook.

The Runtime error 1004 means:

Runtime error 1004: Paste method of worksheet class failed.
Runtime error 1004: Copy method of Range Class Failed.

Reference: http://support.microsoft.com/kb/905164

查看更多
登录 后发表回答