OLE对象插入更改对象格式

时间:2014-03-17 23:25:09

标签: excel-vba vba excel

我使用以下脚本自动将签名PDF图像插入文档以充当签名。但是,当插入pdf时,会自动在我不想要的图像上添加边框。如何修改对象的格式,使其没有边框或线条。

我尝试过使用' ActiveSheet.Shapes.Line.Visible = msoFalse'但这不起作用。

Option Explicit

Sub Insert_signature()
' this part of the script creates a temp filename in the temp folder.
    Dim strPathname As String
    On Error Resume Next
    strPathname = "http://Clearance Handover/Forms/Signature.pdf"

    'MsgBox = ("you are formally authorising the sign off")

    Call insert_pdf_to_Checklist1(strPathname)
End Sub

Sub insert_pdf_to_Checklist1(pdfpath As String)
Dim Xl, Ws, Ol
' This creates an image of the pdf created and
    Set Ws = ActiveWorkbook.Worksheets("Checklist1")
    Set Ol = Ws.OLEObjects.Add(, pdfpath, False, False)

         With Ol
            .Left = Ws.Range("E48:E48").Left
            .Height = Ws.Range("E48:E48").Height
            .Width = Ws.Range("E48:E48").Width
            .Top = Ws.Range("E48:E48").Top
         End With
End Sub 

干杯!

1 个答案:

答案 0 :(得分:2)

以下代码应该工作:)。的测试

Option Explicit
Sub Insert_signature()
    Dim strPathname As String
    strPathname = "C:\Users\ksathis\Documents\Outlook Files\VBASQL.pdf"
    Call insert_pdf_to_Checklist1(strPathname)
End Sub

Sub insert_pdf_to_Checklist1(pdfpath As String)
Dim Xl, Ws
Dim ole As OLEObject
    Set Ws = ActiveWorkbook.Worksheets("Checklist1")
    Set ole = Ws.OLEObjects.Add(, pdfpath, False, False)
    With ole
            .Left = Ws.Range("E48:E48").Left
            .Height = Ws.Range("E48:E48").Height
            .Width = Ws.Range("E48:E48").Width
            .Top = Ws.Range("E48:E48").Top
            .Interior.Color = vbWhite
            .Border.LineStyle = 0
            .Border.Color = vbWhite
         End With
End Sub