Consulting

Results 1 to 2 of 2

Thread: Attaching Objects Code

  1. #1

    Attaching Objects Code

    Hi,

    I have an excel sheet where 1 column has certain text. I have PDF files in a folder & they are saved as per the text in the column.

    For Example, if the column E1 has text "ABC_1234", there is a pdf saved by the same name and so on.

    I need a code that will look at the text in the column, go to a given folder & attach the corresponding PDF's in another column.

    I have a code that activates attaching objects, but I am not sure on how to get it to certain folders/files.

    My code is as below:

    [VBA] Sub Attach_Objects

    Range("A1").Select
    Selection.End(xlToRight).Select
    Selection.Copy
    Application.CutCopyMode = False
    ActiveSheet.OLEObjects.Add(ClassType:="AcroExch.Document", Link:=False, _
    DisplayAsIcon:=True, IconFileName:= _
    "C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe", IconIndex:=1, _
    IconLabel:="").Activate
    Selection.ShapeRange.PictureFormat.CropRight = 17.25
    Selection.ShapeRange.PictureFormat.CropBottom = 22.51
    Selection.ShapeRange.PictureFormat.CropLeft = 19.5
    Selection.ShapeRange.PictureFormat.CropBottom = 21.76

    End Sub[/VBA]

  2. #2
    I forgot to mention that the number of objects to be attached may vary from 10 to over 300. I think to cover that part I could use:

    [VBA] For x = 1 to 1000
    If Cells(x,3).Value = "" Then
    x = 1001
    Else
    (Start & Continue with attaching objects)
    End If
    Next x[/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •