Saltar al contenido

copiar al portapapeles acceso ejemplo de código vba

Posteriormente a indagar en varios repositorios y páginas webs al final nos hemos encontrado la respuesta que te enseñamos aquí.

Ejemplo 1: excel vba portapapeles de windows

'VBA function to read and write text to the Windows clipboard.Function Clipboard$(Optional s$)Dim v: v = s  'Cast to variant for 64-bit VBA supportWith CreateObject("htmlfile")With.parentWindow.clipboardData
        SelectCaseTrueCase Len(s):.setData "text", v
            CaseElse:   Clipboard =.getData("text")EndSelectEndWithEndWithEndFunction'--------------------------------------------------------------------'Three examples of copying text to the clipboard:
Clipboard "Excel Hero was here."
Clipboard var1 & vbLF var2
Clipboard 123'To read text from the clipboard:
MsgBox Clipboard

'Note:	This is a solution that does NOT use MS Forms 'nor the Win32 API. Instead it uses the Microsoft HTML Object Library 'which is fast and ubiquitous; and this solution respects line feeds.

Ejemplo 2: excel vba copia a string al portapapeles

'VBA function to read and write text to the Windows clipboard.Function Clipboard$(Optional s$)Dim v: v = s  'Cast to variant for 64-bit VBA supportWith CreateObject("htmlfile")With.parentWindow.clipboardData
        SelectCaseTrueCase Len(s):.setData "text", v
            CaseElse:   Clipboard =.getData("text")EndSelectEndWithEndWithEndFunction'--------------------------------------------------------------------'Three examples of copying text to the clipboard:
Clipboard "Excel Hero was here."
Clipboard var1 & vbLF & var2
Clipboard 123'To read text from the clipboard:
MsgBox Clipboard

'Note:	This is a solution that does NOT use MS Forms 'nor the Win32 API. Instead it uses the Microsoft HTML Object Library 'which is fast and ubiquitous; and this solution respects line feeds.

Aquí puedes ver las comentarios y valoraciones de los lectores

Te invitamos a auxiliar nuestro análisis dejando un comentario o dejando una puntuación te estamos eternamente agradecidos.

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)


Tags : /

Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *