Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi;
I have two seperate workbooks open and each running a macro that do different types of copy and pastespecial routines. By themselevs (eg. when only one file is open and running) the macro runs fine. Each macro prefroms a copy and pastespecial routine at different intervals. One runs every 60 secs and the other runs every 15 secs. When i run both marcos with the files open and i step away i (not interacting with either file, etc.) I get a error routinely that reads "pastespecial of Range Class Failed Error 1004". Without dumping the code in here do you have any ideas what this could be caused by? The two macros confliciting somehow with clipboard, or thier timing is being conflicted? Thanks DaveM |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
The clipboard is a shared resource and one macro using or clearing it could
interfere with the other. You might consider setting a flag of some sort when a macro starts its copy and clearing it when done. The macro would also have to check if the flag is already set before it does its copy. A flag could be a text file or an INI file entry or registry entry. -- Jim "DaveM" wrote in message ... | Hi; | I have two seperate workbooks open and each running a macro that do | different types of copy and pastespecial routines. By themselevs (eg. when | only one file is open and running) the macro runs fine. Each macro prefroms | a copy and pastespecial routine at different intervals. One runs every 60 | secs and the other runs every 15 secs. | | When i run both marcos with the files open and i step away i (not | interacting with either file, etc.) I get a error routinely that reads | "pastespecial of Range Class Failed Error 1004". | | Without dumping the code in here do you have any ideas what this could be | caused by? The two macros confliciting somehow with clipboard, or thier | timing is being conflicted? | | Thanks | DaveM |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks Jim......I understand what you mean by a flag (essentially a traffic
light) but i'm not sure how to implement from your ideas listed..... I've listed an abridged version of the three macros that i run in each of the two seperate workbooks along with some explaination. What would the code look like that you mention and where in this would you suggest I place it? Thanks in advance I appreciate the help... DaveM Sub StartIt() €˜This starts the copy macro timing interval Application.OnTime Now, "UpDateSub" End Sub Sub StopIt() €˜This stops the copy macro timing interval Application.OnTime mdNextTime, "UpDateSub", , False End Sub Sub UpDateSub() €œThis is a simple/abrigdged version of what the copy/paste macro is doing€¦. €¦€¦ €¦€¦. Copy various cells from one sheet and pastespecial just their values into a 2nd sheet w/in the workbook €¦€¦€¦€¦. €¦€¦€¦€¦€¦ Open a text file and append the new values from the pasted worksheet into this text file€¦. Note each marco appends a different text file€¦another words the two macros DONt append data to a common txt file€¦they are different txt files for each macro€¦ €¦€¦.. Close the txt files and wait for next timing interval €¦€¦ €¦€¦. €˜This code sets the timing interval for the macro. €˜As noted in my previous post one marco runs at 15 sec interval and the other at 1 min. mdNextTime = Now + TimeValue("00:01:00") Application.OnTime mdNextTime, "UpdateSub" €¦€¦€¦€¦€¦ End Sub "Jim Rech" wrote: The clipboard is a shared resource and one macro using or clearing it could interfere with the other. You might consider setting a flag of some sort when a macro starts its copy and clearing it when done. The macro would also have to check if the flag is already set before it does its copy. A flag could be a text file or an INI file entry or registry entry. -- Jim "DaveM" wrote in message ... | Hi; | I have two seperate workbooks open and each running a macro that do | different types of copy and pastespecial routines. By themselevs (eg. when | only one file is open and running) the macro runs fine. Each macro prefroms | a copy and pastespecial routine at different intervals. One runs every 60 | secs and the other runs every 15 secs. | | When i run both marcos with the files open and i step away i (not | interacting with either file, etc.) I get a error routinely that reads | "pastespecial of Range Class Failed Error 1004". | | Without dumping the code in here do you have any ideas what this could be | caused by? The two macros confliciting somehow with clipboard, or thier | timing is being conflicted? | | Thanks | DaveM |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I don't have code for this but just before the macro copies it should check
the 'clipboard busy' flag (I'd use the registry GetSetting/SaveSetting]). If it's busy then go into loop where you check the flag again every second or so. When it's not busy, set the busy flag and do your copy/paste. Then clear the busy flag. There is the potential danger that a macro breaks before it clears the busy flag so it's always busy. I would consider counting the number of times the loop runs and if it's greater than some arbitrary safe number assume the other macro broke and ignore the flag. -- Jim "DaveM" wrote in message ... | Thanks Jim......I understand what you mean by a flag (essentially a traffic | light) but i'm not sure how to implement from your ideas listed..... | | I've listed an abridged version of the three macros that i run in each of | the two seperate workbooks along with some explaination. What would the code | look like that you mention and where in this would you suggest I place it? | | Thanks in advance I appreciate the help... | | DaveM | | Sub StartIt() 'This starts the copy macro timing interval | Application.OnTime Now, "UpDateSub" | End Sub | | Sub StopIt() 'This stops the copy macro timing interval | Application.OnTime mdNextTime, "UpDateSub", , False | End Sub | | Sub UpDateSub() "This is a simple/abrigdged version of what the copy/paste | macro is doing.. | .. | ... | Copy various cells from one sheet and pastespecial just their values into a | 2nd sheet w/in the workbook | ..... | ..... | Open a text file and append the new values from the pasted worksheet into | this text file.. | Note each marco appends a different text file.another words the two macros | DON't append data to a common txt file.they are different txt files for each | macro. | .... | | Close the txt files and wait for next timing interval | .. | ... | 'This code sets the timing interval for the macro. | 'As noted in my previous post one marco runs at 15 sec interval and the | other at 1 min. | | mdNextTime = Now + TimeValue("00:01:00") | Application.OnTime mdNextTime, "UpdateSub" | ..... | End Sub | | | | | "Jim Rech" wrote: | | The clipboard is a shared resource and one macro using or clearing it could | interfere with the other. You might consider setting a flag of some sort | when a macro starts its copy and clearing it when done. The macro would | also have to check if the flag is already set before it does its copy. A | flag could be a text file or an INI file entry or registry entry. | | -- | Jim | "DaveM" wrote in message | ... | | Hi; | | I have two seperate workbooks open and each running a macro that do | | different types of copy and pastespecial routines. By themselevs (eg. | when | | only one file is open and running) the macro runs fine. Each macro | prefroms | | a copy and pastespecial routine at different intervals. One runs every 60 | | secs and the other runs every 15 secs. | | | | When i run both marcos with the files open and i step away i (not | | interacting with either file, etc.) I get a error routinely that reads | | "pastespecial of Range Class Failed Error 1004". | | | | Without dumping the code in here do you have any ideas what this could be | | caused by? The two macros confliciting somehow with clipboard, or thier | | timing is being conflicted? | | | | Thanks | | DaveM | | | |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
PasteSpecial Method Error | Excel Discussion (Misc queries) | |||
Runtime Error 1004 when trying to PasteSpecial | Excel Discussion (Misc queries) | |||
Run time error 1004, General ODBC error | New Users to Excel | |||
Runtime error '1004' General ODBC error | New Users to Excel | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) |