Run-time error '1004' in Win10 not Win7

MichaelRSnow

Active Member
Joined
Aug 3, 2010
Messages
409
Hi

I get the following error on the below code (Run-time error '1004' Application-defined or object-defined error), which is very strange as when I run this on my windows 7 machine it runs fine but when I run it from my Windows 10 machine it falls over. Also if it step through the code manually with F8 on the Windows 10 machine it also works fine?

Any ideas? I'm stumped ?


VBA Code:
'paste output in destination format
ThisWorkbook.Worksheets(sheetName).PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
False, NoHTMLFormatting:=True
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Do both PCs have same Excel version?
 
Upvote 0
Can you post the 2 lines above the one you posted please. I suspect that you are coming out of copy mode before the paste.
 
Upvote 0
Hey Mark858, yeah I think you are right as when I placed a MsgBox above the code to confirm the Scenario being pasted it stopped the error, this was the previous code below, what is the best solution to overcoming this? My MsgBox solution isn't the best idea


VBA Code:
'results page
ie.ExecWB 17, 0 '// SelectAll
ie.ExecWB 12, 2 '// Copy selection

'creates sheet and names it 'scenario x'
scenarioNumber = shtMacro.Range("B2").Value
sheetName = "Scenario" & scenarioNumber
Worksheets.Add().Name = sheetName
 
Upvote 0
Try moving the Select/Copy below the Worksheets.Add
 
  • Like
Reactions: Zot
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,582
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top