إدراج صورة للكلمة ، تغيير حجم الصور ، حدود إدراج باستخدام VBA إكسل

يدرج البرنامج صورة لملف كلمة وتغيير حجم الصور وإدراج الحدود.

تفسير

تم تطوير هذا البرنامج VBA لاستخراج صورة وتضاف إلى ملف كلمة تغيير حجم الصورة وفقا للإعدادات في ورقة العمل ، وتحيط صورة مع الحدود. ويمكن للصورة أن يعاد الحجم باستخدام هذا الرمز ولكن الصورة لن تتغير من حيث الحجم بالكيلو. لضغط صورة باستخدام VBA غير ممكن هذا الذي ينبغي القيام به يدويا.

من أجل جعل عمل برنامج المرجع "مايكروسوفت وورد xx.x مكتبة كائنات" يجب تمكين.

مثلا ملف رمز VBA يتوفر للتحميل في أسفل صفحة الويب هذه ، يتمتع! أو مجرد نسخ ولصق رمز مباشرة من هذه الصفحة.

رمز

Public Sub Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel()

Dim Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel_APP As Word.Application
Dim Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel_DOC As Word.Document
Set Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel_APP = CreateObject("Word.Application")

Dim PlaceOfWordFile As String
Dim NameOfWordFile As String

PlaceOfWordFile = Range("B4").Value
NameOfWordFile = Range("B5").Value

PlaceOfImageFile = Range("B6").Value
NameOfImageFile = Range("B7").Value

NamePlaceImage = PlaceOfImageFile + "\" + NameOfImageFile
NamePlace = PlaceOfWordFile + "\" + NameOfWordFile

Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel_APP.Visible = True

Set Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel_DOC = Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel_APP.Documents.Open(NamePlace, ReadOnly:=False)

Set WORD_Image = Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel_APP.Selection.InlineShapes.AddPicture(NamePlaceImage, False, True)
   
HeightOfImage = Range("D5").Value
   
With WORD_Image
    H = .Height
    B = .Width
    Ratio = H / B
    .Height = HeightOfImage
    .Width = HeightOfImage / Ratio
End With

WORD_Image.Borders.OutsideLineStyle = wdLineStyleSingle

Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel_DOC.Save
Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel_APP.Quit

Set Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel_DOC = Nothing
Set Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel_APP = Nothing

End Sub


 

 

 

تنزيل ملف اكسل!Insert_Image_to_Word_Resize_Image_Insert_Borders_using_VBA_Excel.xls

 

Add your comment

Your name:
Subject:
Comment: