Run time error 2147221040 800401d0

Getting run-time error '-2147221040 (800401d0)': DataObject:PutInClipboard OpenClipboard Failed Any workaround on this error? Macro takes everything currently on the clipboard, parses through it, pulling specific pieces out, then pastes it into excel. Get this error every time.

joe.afusco

Board Regular

Joined
Jun 25, 2010
Messages
80


  • #1

Getting run-time error ‘-2147221040 (800401d0)’:

DataObject:PutInClipboard OpenClipboard Failed

Any workaround on this error?

Macro takes everything currently on the clipboard, parses through it, pulling specific pieces out, then pastes it into excel. Get this error every time.

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

migforce

New Member

Joined
Feb 27, 2013
Messages
1


  • #2

Getting run-time error ‘-2147221040 (800401d0)’:

DataObject:PutInClipboard OpenClipboard Failed

Any workaround on this error?

Macro takes everything currently on the clipboard, parses through it, pulling specific pieces out, then pastes it into excel. Get this error every time.

Did you ever solve this?
Thanks.

joe.afusco

Board Regular

Joined
Jun 25, 2010
Messages
80


  • #3

Did you ever solve this? Thanks.

We do still get this error from time to time. We run the macro that uses open clipboard roughly 15k times a day. Restarting the station helps fix it. When the issue was more consistent, I noticed the guy who wrote the code for us didn’t kill off his variables on completing execution of the code. Maybe try that?

Similar threads

Fluff

MARK858

Поскольку это не получало ответа в течение нескольких лет, и SandPiper предложила мне поделиться ответом, я расскажу о том, что я сделал, в качестве работы.

Некоторый контекст — раньше я работал в компании, которая использовала 64-битный Excel 365, и этого никогда не происходило (включая Excel 2019). Однако недавно я присоединился к новой компании, и они используют 32-разрядную версию Excel 2016 — по определенным бизнес-причинам. При этом, если вы используете более позднюю версию, это решение может сработать для вас, но, кроме того, вы также можете попробовать следующее решение.

Так зачем упомянуть вышеупомянутое? Проблема, с которой я столкнулся с 32-битным Excel, заключалась в том, что выделение виртуальной памяти, которое используется Excel для выполнения таких операций с copy и paste, очень ограничено по сравнению с 64-битными версиями. Таким образом, при использовании 32-битного Excel обычно используется эта виртуальная память и, следовательно, возникает ошибка времени выполнения.

Имея это в виду, одним из решений, которые я придумал, было использование метода Application.Wait, который в принципе дает Excel (приложению) достаточно времени, чтобы догнать программу и позволить ей выполнить команду. Я обнаружил, что лучше всего было заключить это в цикл while, чтобы дать несколько попыток в производственной среде. Пожалуйста, посмотрите код ниже — надеюсь, это поможет другим.

Option Explicit

Sub SelectedRangeToImage()

    Const maxPasteAttempts As Long = 5
    Dim iPaste As Long
    Dim tmpChart As Chart, n As Long, shCount As Long, sht As Worksheet, sh As Shape
    Dim fileSaveName As Variant, pic As Variant
    
    'Create temporary chart as canvas
    Set sht = Selection.Worksheet
    Selection.Copy
    sht.Pictures.Paste.Select
    
    Set sh = sht.Shapes(sht.Shapes.Count)
    Set tmpChart = Charts.Add
    
    tmpChart.ChartArea.Clear
    tmpChart.Name = "PicChart" & (Rnd() * 10000)
    
    Set tmpChart = tmpChart.Location(Where:=xlLocationAsObject, Name:=sht.Name)
    tmpChart.ChartArea.Width = sh.Width
    tmpChart.ChartArea.Height = sh.Height
    tmpChart.Parent.Border.LineStyle = 0
    
    'Paste range as image to chart
    On Error Resume Next
    While Err.Number <> 0
        Application.Wait Now() + "00:00:01"
        sh.Copy
        tmpChart.ChartArea.Select
        Application.Wait Now() + "00:00:01"
        tmpChart.Paste
        ' handling while loop
        iPaste = iPaste + 1
        If iPaste >= maxPasteAttempts Then
            MsgBox "Failed to paste - please consult developer.", vbCritical, "Fatal error"
            On Error GoTo 0
            Exit Sub
        End If
    Wend
    On Error GoTo 0
    
    'Save chart image to file
    fileSaveName = Application.GetSaveAsFilename(fileFilter: = "Image (*.jpg), *.jpg")
    If fileSaveName <> False Then
      tmpChart.Export Filename:=fileSaveName, FilterName: = "jpg"
    End If
    
    'Clean up
    sht.Cells(1, 1).Activate
    sht.ChartObjects(sht.ChartObjects.Count).Delete
    sh.Delete

End Sub
  • Home
  • VBForums
  • Visual Basic
  • Office Development
  • [RESOLVED] vba — unstable code for clipboard

  1. Aug 28th, 2006, 12:57 AM


    #1

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Resolved [RESOLVED] vba — unstable code for clipboard

    Hi guyz,

    I used this bunch of codes. the mydata.getfromclipboard fails once in a while and it passes once in a while, any ideas?

    <vbcode>
    Dim myData As DataObject
    Dim Temp As String

    Set myData = New DataObject

    selection.Copy
    myData.GetFromClipboard
    Temp = myData.GetText
    </vbcode>

    Last edited by ryanlum; Aug 28th, 2006 at 04:29 AM.


  2. Aug 28th, 2006, 01:56 AM


    #2

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard


  3. Aug 28th, 2006, 02:17 AM


    #3

    Re: vba — unstable code for clipboard

    What office app are you using? Do you get any error messages and if so what are they?

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  4. Aug 28th, 2006, 02:20 AM


    #4

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    i am using office 2003
    i got this run time error
    runtime error ‘-2147221040 (800401d0)’
    any idea?
    thx in advance


  5. Aug 28th, 2006, 02:30 AM


    #5

    Re: vba — unstable code for clipboard

    This is the translated error message for that number …

    -2147418094 (80010012) The callee (server [not server application]) is
    not available and disappeared; all connections
    are invalid. The call did not execute.

    What are you copying from and pasting into?

    Moved

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  6. Aug 28th, 2006, 02:30 AM


    #6

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    just to add.. i am using msoffice


  7. Aug 28th, 2006, 02:31 AM


    #7

    Re: vba — unstable code for clipboard

    Are you doing this between two Office apps?

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  8. Aug 28th, 2006, 02:31 AM


    #8

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    i am just copying something that i typed out. for instance
    the word «HI»
    i copied the whole word into the clipboard and i want use it for pasting and putting it into a variable.


  9. Aug 28th, 2006, 02:35 AM


    #9

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    nope.. just within ms word


  10. Aug 28th, 2006, 02:44 AM


    #10

    Re: vba — unstable code for clipboard

    Easier way to do this is…

    VB Code:

    1. Dim sString As String

    2. If TypeName(Selection) <> "Nothing" Then

    3.     sString = Selection

    4.     MsgBox sString

    5. Else

    6.     MsgBox "Nothing Selected"

    7. End If

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  11. Aug 28th, 2006, 02:56 AM


    #11

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    I get something like this «test .» there is a big dot behind.. this is the coding i am using

    btw.. side track abit. is there anyway to use step in vba? becuase i only see a run and break points

    VB Code:

    1. Sub DocCbl()

    2.  Dim Temp       As String

    3.  Dim UTemp      As String

    4.  Dim LTemp      As String

    5.  Dim Count      As Integer

    6.  With Selection

    7. ' Getting the initial value

    8.     .MoveLeft Unit:=wdCharacter, Count:=1

    9.     .HomeKey Unit:=wdLine

    10.     .EndKey Unit:=wdLine, Extend:=wdExtend

    11.     Temp = Selection

    12.     UTemp = UCase(Temp)

    13.     LTemp = LCase(Temp)

    14.     .Delete

    15. ' Setting the Format and the values

    16.     .HomeKey Unit:=wdLine

    17.     .TypeText Text:="CDS-" + UTemp

    18.     .HomeKey Unit:=wdLine

    19.     .EndKey Unit:=wdLine, Extend:=wdExtend

    20.     Call FontSetting

    21.     .EndKey

    22.     .TypeParagraph

    23.     .Font.Size = 9

    24.     .Font.Name = "Courier New"

    25.     .Font.Bold = False

    26.     .TypeText Text:=LTemp + ".sh"

    27.     .MoveUp Unit:=wdLine, Count:=2

    28.     .MoveLeft Unit:=wdCell

    29.     .HomeKey Unit:=wdLine

    30.     .EndKey Unit:=wdLine, Extend:=wdExtend

    31.     Count = Val(Selection)

    32.     Count = Count + 1

    33.     .MoveDown Unit:=wdLine, Count:=1

    34.     Call FontSetting

    35.     .TypeText Text:=Count

    Last edited by RobDog888; Aug 28th, 2006 at 03:04 AM.

    Reason: Added [vbcode] tags


  12. Aug 28th, 2006, 03:05 AM


    #12

    Re: vba — unstable code for clipboard

    Yes, you place a breakpoint and run your code. Then when it breaks you can press F8 to execute a single line of code for each keypress.

    Is the text needing to be set to a variable with formatting? Is it just text?

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  13. Aug 28th, 2006, 03:13 AM


    #13

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    I just declared it as a normal string
    no formatting is required.. the result is something like this «SADASD

    dunno why there is a big black dot there somemore


  14. Aug 28th, 2006, 03:25 AM


    #14

    Re: vba — unstable code for clipboard

    Thats a square Just an unsupported ascii character like a line break. Your selection covers two or more lines?

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  15. Aug 28th, 2006, 03:52 AM


    #15

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    nope… only a single line
    but when i select it.. i copy the whole line using either home or end


  16. Aug 28th, 2006, 03:59 AM


    #16

    Re: vba — unstable code for clipboard

    What is the actual text that your selecting?

    SADASD
    S

    Is the square char an apostrophy or something?

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  17. Aug 28th, 2006, 04:02 AM


    #17

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    For example.. i key in SADSD then i will select it and do a copy… but when i paste, it will come out as below

    SADASD
    S


  18. Aug 28th, 2006, 04:04 AM


    #18

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    the black dot only came out when i switch to the selection method that you recommended.. if i was using the clipboard method, this error didn’t come out


  19. Aug 28th, 2006, 04:04 AM


    #19

    Re: vba — unstable code for clipboard

    But thats a different set of chars?

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  20. Aug 28th, 2006, 04:07 AM


    #20

    Re: vba — unstable code for clipboard

    Ah, the square is a line break character — 13. We can cut it off and just keep that chars.

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  21. Aug 28th, 2006, 04:09 AM


    #21

    Re: vba — unstable code for clipboard

    This will remove all 13’s from the selection. We can change it if you need to only remove the trailing 13.

    VB Code:

    1. Dim sString As String

    2. If TypeName(Selection) <> "Nothing" Then

    3.     sString = Replace(Selection, Chr(13), vbNullString)

    4.     MsgBox sString

    5. Else

    6.     MsgBox "Nothing Selected"

    7. End If

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  22. Aug 28th, 2006, 04:10 AM


    #22

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    ahh.. hey i found out how to solve the problem already.

    hahaha i just need to add the typename(selection)
    so typename here can be used as some sort of clipboard right?


  23. Aug 28th, 2006, 04:12 AM


    #23

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: [RESOLVED] vba — unstable code for clipboard

    o ya… is there a way to solve the clip board problem earlier?
    i did some searching and there seem to be alot of problems with the clip board


  24. Aug 28th, 2006, 04:13 AM


    #24

    Re: [RESOLVED] vba — unstable code for clipboard

    No, the Selection object is the actual highlighted selection in your word document. The TypeName on the Selection object is checking for an actual selection as a means of error trapping for if there is an selection already made.

    You werent using my exact code?

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  25. Aug 28th, 2006, 04:14 AM


    #25

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: [RESOLVED] vba — unstable code for clipboard

    erm.. sorry for the misleading news.. i still can’t solve it yet =.=»anyway to remove the resolved icon from the side?


  26. Aug 28th, 2006, 04:16 AM


    #26

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: [RESOLVED] vba — unstable code for clipboard

    nope.. i have to modify it a lil to accomodate for my code…
    this is what i used. anything i key in… will have a black dot at the back

    VB Code:

    1. With Selection

    2.     Temp = Selection

    3.     UTemp = UCase(Temp)

    4.     LTemp = LCase(Temp)

    5. End with


  27. Aug 28th, 2006, 04:25 AM


    #27

    Re: [RESOLVED] vba — unstable code for clipboard

    See post #21 for the resolution.

    To un-resolve your thread, just edit the first post and remove the «[RESOLVED]» from the Subject and switch the subject icon, then save.

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  28. Aug 28th, 2006, 04:48 AM


    #28

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    hey..
    i did a few extra steps to get rid of the black dot.. like backspace twice.. is there a more efficient way to get ride of it?


  29. Aug 28th, 2006, 04:55 AM


    #29

    Re: vba — unstable code for clipboard

    Yes, as posted earlier — Post #21. Note the Replace function

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  30. Aug 28th, 2006, 05:02 AM


    #30

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    but in the selection function you fixed the number of bytes to 13.. if its longer then 13?
    is there away not to fix it but take the whole word insteaD?


  31. Aug 28th, 2006, 05:07 AM


    #31

    Re: vba — unstable code for clipboard

    No, the Replace function «replaces» the designated string or character with whatever you specify in its replace argument. In this case I am searching for the line break (chr(13) or vbNewline or vbCrLf) and then when found it switches it to a empty string (no space or char) «».

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  32. Aug 28th, 2006, 05:17 AM


    #32

    ryanlum is offline

    Thread Starter


    Fanatic Member


    Re: vba — unstable code for clipboard

    thx for your help. it looks ok now


  33. Aug 28th, 2006, 05:18 AM


    #33

    Re: [RESOLVED] vba — unstable code for clipboard

    VB/Office Guru� (AKA: Gangsta Yoda)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum. Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru� Word SpellChecker�.NETVB/Office Guru� Word SpellChecker� VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24″ LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6


  • Home
  • VBForums
  • Visual Basic
  • Office Development
  • [RESOLVED] vba — unstable code for clipboard


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
  • BB code is On
  • Smilies are On
  • [IMG] code is On
  • [VIDEO] code is On
  • HTML code is Off

Forum Rules


Click Here to Expand Forum to Full Width

Run-time Error -2147221040 (800401d0) — Excel

Getting run-time error ‘-2147221040 (800401d0)’:

DataObject:PutInClipboard OpenClipboard Failed

Any workaround on this error?

Macro takes everything currently on the clipboard, parses through it, pulling specific pieces out, then pastes it into excel. Get this error every time.

Excel VBA Course

Excel VBA Course — From Beginner to Expert

200+ Video Lessons
50+ Hours of Instruction
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

(80% Discount Ends Soon!)

View Course


Similar Topics



How can i solve a debugger error that states «run-time error ‘9’…Subscript out of range.

for a search box code provided by Joe Was

View Answers


Is there an on error exit sub command. I would like my Macro to just stop running if there is an error instead of an error message popping up. Thanks in advance

View Answers


Hi all,

I’ve been getting this error on occasion recently.

— It’s a shared document
— There is usually 10-12 people using the file at the same time

I’ve read on the Microsoft Help site that the issue is that somebody is accessing the file while another is trying to open it.

Is there a way, perhaps through VBA, that I can not allow a user to save while somebody else is opening the document? Other suggestions on how to avoid this error?

Thanks!

View Answers


Is it possible to share a workbook with macros and have the macros work properly. I have one spreadsheet that needs to be shared by many users. We want to all be in the same document at the same time saving changes. The real catch is that the workbook has macros. I used the ‘Share Workbook’ function under tools. At the end of the setup, it told me that the macros would not work properly. The odd thing is that everytime I try to click on one of the macros I get an error, but yet the macro still performs the function. So essentially the macro works, it is just a pain because you have to click ‘end’ everytime on the error screen. Any suggestions?

Alanda

View Answers


I have a large spreadsheet in Excel 2007. I am converting it to a .csv file to import in to another program. I need to delete all commas from all data.

When I try to replace all commas (with nothing or with another character), I get the error message «The formula you typed contains an error.»

I have tried various formats (text, general, etc.) and various file types (.xls,.xlsx, .csv) and still get the same error.

View Answers


I am trying to figure out how to write a formula to figure out production cycle time.
We will be building 8 «widgets» a day.
We will work 10 hours a day.
There is a 20 minute break at 9:20 am.
Production shuts down for lunch 30 minutes for lunch at 12:30.
Production starts at 6:00 am.
Here is what I can do.
Production cycle time = (10*60)-30/8 or 71.25 minutes
If we start at 6:00 am, the first scheduled cycle completion time = TIME(6,0,0+71.25/1440)

My problem is when I am trying to use a logical «IF’ statement to account for the 20 minute break or lunch and still calculate the end of each cycle time through the day I receive a number of error messages.
This is the formula I am trying to make work. I have the cell the formula is in, formatted with a «mm,ss» format.
=(IF(D4+G1/1440>9:20,(D4+G1)/24,(D4+G1+15)/1440))
I have included an attachment to help (a picture is worth a thousand words).

Any help will be greatly appreciated.
I have bought a number of books in an attempt to figure this out, and I am still stumped

View Answers


Happy Day to all,

Can you please help me,

A1= time in
B1= time out
C1= time in
D1= time out

I want to calculate the late and under time,
Office start at 9:am w/30 mins Grace period,
The break time is one hour only, please include over breaktime in calculation.
End of office hours 6:00 pm, strickly no over time

View Answers


Hi all,

I’ve had a long search through your pages to see if this question has been answered before but having browsed through about 50 pages worth of threads I couldn’t see anything, but if I am repeating prior information I do apologise.

I’ve written a macro that is relatively simple. It just takes some information in one format, rearranges it, adds some formatting and performs some calculations. Nothing incredibly fancy but it works fine on my computer.

Now, I need to share this macro with some other people, so basically I’ve just sent that excel file on to the people that need to use it. Should be fine and in most cases it is, however there is one user who although they can open the file, can’t seem to get the macro to run properly.

It seems to get a small way through the macro but then stop with no error messages or any sign that it hasn’t completed properly.

I have checked Macro Security level and that is the same as mine, Tools — Add-Ins is the same, In Visual Basic, Tools — References is the same as mine. It is the same Operating system and the same version of Excel.

I have even signed into this person’s computer as myself (it’s a big company network thing) and tried to run the macro and it works fine, so there is nothing wrong with the hardware.

I’ve googled and searched and tried everything I can think of but I’m no closer to solving this problem, so if anyone has read through this wall of text and can come up with a possible solution, that would be greatly appreciated to save me from tearing ALL my hair out!

Thanks very much for your time.

View Answers


Good day… I need an IF Function that will allow me to action a time in a time range:

… If the time 04:16 falls in the time range 04:00 — 04:29, than put a one (1) in the filed x…
… If the time 04:16 doesn’t fall in the time range 04:00 — 04:29, than leave the x fiel empty

Any help is appreciated.

View Answers


In Excel I have been trying to find an easier way to calculate a time
difference where the times cross midnight. Example:
Start time: 23:50:00
End time: 00:15:00

How would you formulate an equation to determine the duration of time or
differnce between the start and end time?

View Answers


i have a worksheet with formulas in 15,000 cells; i have set the calculation to maunal so that you have to press F9 to calculate the sheet.

sometimes, it takes 45 seconds to calc the whole sheet, other times, it takes 5 minutes. how do i clear the cache, or what do i have to do so that it calcs 45 seconds each time.

i don’t want the application to think, it would be better if those 15,000 cells can be returned in a fraction-of-a-second. any ideas/tips? thanks.

View Answers


Hello,

Please help!!!
We have a client who will pay using the 1/4, 1/2/ and 3/4 of an hour increments as follows:

From the hour mark to 6 minutes = 0 time paid
Over 7 minutes to 15 minutes = 1/4 hour 15
16 minutes to 30 minutes = 1/2 hour 30
30 minutes to 45 minutes = 3/4 hour 45
46 minutes to 60 minutes = one hour.

They work on shifts and the operation is 24 hours. Each gets 30 minutes for breaks which is not paid. Pay is biweekly and overtime is anything over 40 hours. Currently, the template we are using looks like this (sorry, I could not figure out how to paste it so you can see it in Excel layout):
WEEK 1 Sunday Monday Tuesday Wednesday Thursday Friday Saturday
5/16 5/17 5/18 5/19 5/20 5/21 5/22
TIME IN ENTER TIME, INCLUDE AM OR PM
TIME OUT
TIME IN
TIME OUT
TIME IN
TIME OUT
TIME IN Total Hours First Week
TIME OUT
HOURS WORKED-OR- choose one
*HOLIDAY WORKED
PAID HOLIDAY (not worked)
*OTHER PAID HOURS
EXPLANATION OF *HOLIDAY WORKED HRS OR *OTHER

I am very new to Excel and need help creating a formula that will allow us to calculate this timesheet? I am in desperate need for help.

Thanks..

View Answers


Sorry for the question. Normally I find answers to my excel questions by going through the help tab or by searching on Google. However, I don’t even know what question to ask on this one!?!

Basically I have created a spreadsheet with several columns, but I have one column that lists the shirt size (YS, YM, YL, AS, AM, AL, XL, 2X, 3X) of each person. Is there a formula that I can create that will tabulate the number of sizes (i.e. AS=2, AM=7, etc.)?

In previous years I made a column for each size, and simply placed a «1» in the correct column, and had excel just add the 1’s from each column. However, that takes more time and space. I was hoping to streamline it this time around.

Thanks for taking the time to read this post. Any help would be appreciated! Thanks, doug

View Answers


Hi Guys,
I need help….I am working production scheduling with Start and End time but there is a lunch time and tea time. Is there any formula to calculate Start time to End time with excluding lunch time?
Here is example :

Lunch time :12:00pm to 1:00pm.
Duration Process :6 hours.
Start Time (8:00am)
End time (5:00 pm)

I need a formula to calculate from Start Time 8:00am and what is the End Time? with 1 hour lunch time…

Thanks,
ET

View Answers


I am attempting to figure out how to change the formula to automatically subtract a 30 minute lunch if the total time for the day exceeds 6 hours worked.

B value Time of day punch in: 9:30 AM
C value =IF(D11=»»,»»,»-«)
D value Time of Day punch out: 6:00 PM
E value =IF(D11=»»,»»,IF(D11

View Answers


I get the error message «reference is not valid» each time I open my spreadsheet. I get this message three times, and once I am done clicking ok on all three of them, my spreadsheet works just fine. The problem is, I have to send it to a bunch people.

I have

a sheet with raw data

a sheet with pivot tables

a sheet with a dashboard

and a simple macro

I don’t have any #REF cells either.

Someone has any idea of what could be the problem?

thanks

NA

View Answers


I found this solution for «drop down list with hyperlink» but it did not work.

Perhaps a better solution is to use a workaround that relies on the HYPERLINK function to refer to whatever is selected in the drop-down list. For instance, if you have your data validation drop-down list in cell A1, then you might put the following formula in cell B1:

=HYPERLINK(A1, «Goto Link»)

The solution directly above provides exactly what I am looking for
in the field where I write the formula, but it fails to hyperlink.
I have created a drop down list and linked each one of them to a
specific worksheet. When I select them individually they link to
appropriate worksheet. But when I select them in the drop down
list I receive the following error when I select the Hyperlink in
cell B1 as directed above.

«Cannot open the specified file»

Any thoughts?

Bob

View Answers


I have an excel worksheet that adds two other worksheets in a data
triangle. I copied it to create a new data set and used find &
replace to change the worksheet references to the new ones.

The cells still contain the result of the old formula referring to the
previous worksheets. The only way I can get the formula to return the
correct result is to edit (F2) each cell and press enter. Calc now
(F9) does nothing.

I’ve seen this before, but this time, I need to calculate many
thousands of cells and don’t have time for this workaround.

Any ideas?

Thanks.

Don S

View Answers


I have created a simple macro in this excel spreadsheet. Everything works fine until I sent the attachment to my boss. It does not work and keep showing s pop up error msg.

What could be wrong?

View Answers


Hello, I am pretty new to excel programming/messing around so I’ll refer to those who are much wiser than I am. I am trying to set up a form for work, in this form I want to have a page with a bunch of cells pre-sized. What I want to do is when I insert a picture from a job site, that when this picture gets inserted, it will automatically resize to fit within the cell. I don’t have time to manually resize dozens of pictures and if I could get this to work it would be awesome! I tried to search for an answer using the search function, but I kept getting a fatal error about allowable memory? Thanks in advance for you help!

View Answers


Понравилась статья? Поделить с друзьями:
  • Run time error 2147023170 800706be
  • Run time error 2146697208 800c0008 как исправить
  • Run time error 19 file or function is not found перевод
  • Rufus ошибка mbr
  • Rufus доступ к устройству запрещен ошибка что делать