KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: help to transfer clipboard into variable in word and back
Topic Summary:
Created On: 05/02/2020 04:31 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 help to transfer clipboard into variable in word and back   - dicdoc - 05/02/2020 04:31 PM  
 help to transfer clipboard into variable in word and back   - speechpro - 05/02/2020 11:55 PM  
Keyword
 05/02/2020 04:31 PM
User is offline View Users Profile Print this message

Author Icon
dicdoc
Top-Tier Member

Posts: 207
Joined: 07/31/2014

HI there,

 

I got this macro working from word, but I get error, say object cannot be created

 

 

===== code

Sub Main
'
'https://wordmvp.com/FAQs/MacrosVBA/ManipulateClipboard.htm
' https://docs.microsoft.com/en-us/office/vba/language/reference/
'user-interface-help/copy-getfromclipboard-gettext-methods-dataobject-object-example
'
'Set References (Tools/References)
' Microsoft Forms 2.0 Reference Library
' Microsoft Word Object Library
'
Dim MyData As DataObject
Dim strClip As String

Set MyData = New DataObject
MyData.GetFromClipboard
strClip = MyData.GetText ' =====> error on this line when macro is used

 ' Chr(0) = "" = Null Caracter
 ' vbNullString = "" car chr(0) n'a pas l'air de marcher
 ' Chr(9) = Tab character
 ' Chr(10) = Linefeed character
 ' Chr(13) = Carriage return character
 ' Chr(32) = barre d'espacement
 ' Chr(35) = "#"
 ' Chr(46) = "."

    ' suppression des tabulations et des marques de Paragraphe
    strClip = Replace(strClip, Chr(35) & Chr(35) & Chr(13), vbNullString)
    strClip = Replace(strClip, Chr(35) & Chr(35), vbNullString)
    strClip = Replace(strClip, Chr(9), vbNullString)
    strClip = Replace(strClip, Chr(10), vbNullString)
    strClip = Replace(strClip, Chr(13), " ")
    strClip = Replace(strClip, "     ", " ")
    strClip = Replace(strClip, "    ", " ")
    strClip = Replace(strClip, "   ", " ")
    strClip = Replace(strClip, "  ", " ")
    strClip = Replace(strClip, " .", ". ")
    strClip = Replace(strClip, " ,", ", ")
    strClip = Replace(strClip, " ;", "; ")
    strClip = Replace(strClip, "   ", " ")
    strClip = Replace(strClip, "  ", " ")

    strClip = Replace(strClip, " : -de", " de")
    strClip = Replace(strClip, ". -de", ", de")
  '  strClip = Replace(strClip, "n : ", ":")



    ' suppression de tout caractère non imprimable
    strClip = Application.CleanString(strClip)

    ' suppression de tout espace en début ou fin de chaine
    strClip = Trim(strClip)

    ' ajout dans le presse papier
    Dim MyResult As New DataObject
    MyResult.SetText strClip
    MyResult.PutInClipboard

    ' collage du presse-papier sans mise en forme au niveau du point d'insertion
    Selection.PasteAndFormat (wdFormatPlainText)

End Sub


-------------------------

Memory: 16GB Microphone Brand and Model: Rec Mic II Operating System: win 10, latest update; Surface Book 2, Processor (CPU) Type & Speed: I7 8650 Soundcard Brand and Model: none Speech Software: Dragon Medical Practice Edition, french version: 4.0 Using KnowBrainer?: No



 05/02/2020 11:55 PM
User is offline View Users Profile Print this message


speechpro
Power Member

Posts: 70
Joined: 11/09/2006

In Word VBA IDE, you need to create a reference to FM20.DLL

Statistics
31594 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 1 users logged in.
The most users ever online was 3936 on 09/08/2015 at 11:44 AM.
There are currently 512 guests browsing this forum, which makes a total of 513 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2020 FuseTalk™ Inc. All rights reserved.