Jump to content

Change font and text size in ClipPut


Recommended Posts

Hi i'm trying to create a ClipPut with differents font size and font and then paste it into word document.

I know in Word document, i can send("^+P") and change the font size, but it's not then best way to do if i have to change the font and size many time in the document.

    ShellExecute("ReportTemplate.doc")
    WinActivate("ReportTemplate.doc [Compatibility Mode] - Word")
    WinWaitActive("ReportTemplate.doc [Compatibility Mode] - Word")
    Sleep (1000)
    ClipPut("Underline Size 16: " & "Bold size 12" & "Normcal size 11")
    Send("^v")

Any idea?

 

 

Link to comment
Share on other sites

this is a logic of _Clipput  , you can start  at here   , probably you must play with some  DLL , sorry i am not much experience about  this but  if you know ,you will try

; #FUNCTION# ====================================================================================================================
; Author ........: Piccaso (Florian Fida)
; Modified.......: Gary Frost (gafrost)
; ===============================================================================================================================
Func _ClipPutFile($sFilePath, $sDelimiter = "|")
    Local Const $GMEM_MOVEABLE = 0x0002, $CF_HDROP = 15

    $sFilePath &= $sDelimiter & $sDelimiter
    Local $nGlobMemSize = 2 * (StringLen($sFilePath) + 20)

    Local $aResult = DllCall("user32.dll", "bool", "OpenClipboard", "hwnd", 0)
    If @error Or $aResult[0] = 0 Then Return SetError(1, _WinAPI_GetLastError(), False)
    Local $iError = 0, $iLastError = 0
    $aResult = DllCall("user32.dll", "bool", "EmptyClipboard")
    If @error Or Not $aResult[0] Then
        $iError = 2
        $iLastError = _WinAPI_GetLastError()
    Else
        $aResult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $GMEM_MOVEABLE, "ulong_ptr", $nGlobMemSize)
        If @error Or Not $aResult[0] Then
            $iError = 3
            $iLastError = _WinAPI_GetLastError()
        Else
            Local $hGlobal = $aResult[0]
            $aResult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hGlobal)
            If @error Or Not $aResult[0] Then
                $iError = 4
                $iLastError = _WinAPI_GetLastError()
            Else
                Local $hLock = $aResult[0]
                Local $tDROPFILES = DllStructCreate("dword pFiles;" & $tagPOINT & ";bool fNC;bool fWide;wchar[" & StringLen($sFilePath) + 1 & "]", $hLock)
                If @error Then Return SetError(5, 6, False)

                Local $tStruct = DllStructCreate("dword;long;long;bool;bool")

                DllStructSetData($tDROPFILES, "pFiles", DllStructGetSize($tStruct))
                DllStructSetData($tDROPFILES, "X", 0)
                DllStructSetData($tDROPFILES, "Y", 0)
                DllStructSetData($tDROPFILES, "fNC", 0)
                DllStructSetData($tDROPFILES, "fWide", 1)
                DllStructSetData($tDROPFILES, 6, $sFilePath)
                For $i = 1 To StringLen($sFilePath)
                    If DllStructGetData($tDROPFILES, 6, $i) = $sDelimiter Then DllStructSetData($tDROPFILES, 6, Chr(0), $i)
                Next

                $aResult = DllCall("user32.dll", "handle", "SetClipboardData", "uint", $CF_HDROP, "handle", $hGlobal)
                If @error Or Not $aResult[0] Then
                    $iError = 6
                    $iLastError = _WinAPI_GetLastError()
                EndIf

                $aResult = DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hGlobal)
                If (@error Or Not $aResult[0]) And Not $iError And _WinAPI_GetLastError() Then
                    $iError = 8
                    $iLastError = _WinAPI_GetLastError()
                EndIf
            EndIf
            $aResult = DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", $hGlobal)
            If (@error Or $aResult[0]) And Not $iError Then
                $iError = 9
                $iLastError = _WinAPI_GetLastError()
            EndIf
        EndIf
    EndIf
    $aResult = DllCall("user32.dll", "bool", "CloseClipboard")
    If (@error Or Not $aResult[0]) And Not $iError Then Return SetError(7, _WinAPI_GetLastError(), False)
    If $iError Then Return SetError($iError, $iLastError, False)
    Return True
EndFunc   ;==>_ClipPutFile

 

Link to comment
Share on other sites

In fact i have a script that catching different string from fields from web page, and then i want to paste these variables into a word document and some variables are Bold, and others are normals

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...