jorge_cab_ro
01-22-2008, 06:58 AM
Hello,
I'm thinking in a program that insert pics into a Word document and manipulating them. I am new to this myself and need to do something similar. In this case, I want to insert multiple pics into a document, but I WOULD LIKE INSERT A COMPLETE DIRECTORY OF PICS and then scale each one to some size. I then want to print the document.
I am looking others codes and I have finding this:
----------------------------------------------
Sub pega_fotos()
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oDummy As Word.InlineShape
Dim i As Long
Set oWord = New Word.Application
Set oDoc = oWord.Documents.Open(FileName:="C:\blank.doc")
oWord.Visible = True
' insert 2 picture files (bitmaps)
Set oDummy = oDoc.InlineShapes.AddPicture(FileName:="Z:\COGNODATA\Proyectos\BCOP - Funcional Datamart Marketing\An?lisis\An?lisis Descriptivos\AUDITOR?A\BDMI_MUNI2\fig_BDMI_MUNI2_x0x5BEMPRESAS_CARACTE RISTICAS_TIPO_ACTIVOS_TOT0x5D.jpg", _
LinkToFile:=False, SaveWithDocument:=True)
Set oDummy = oDoc.InlineShapes.AddPicture(FileName:="Z:\COGNODATA\Proyectos\BCOP - Funcional Datamart Marketing\An?lisis\An?lisis Descriptivos\AUDITOR?A\BDMI_MUNI2\fig_BDMI_MUNI2_x0x5BEMPRESAS_CARACTE RISTICAS_TIPO_AGRARIO_POR0x5D.jpg", _
LinkToFile:=False, SaveWithDocument:=True)
' insert n picture files (bitmaps)
For i = 1 To oDoc.InlineShapes.Count
' scale it
oDoc.InlineShapes(i).Fill.Visible = False
oDoc.InlineShapes(i).Fill.Transparency = 0#
oDoc.InlineShapes(i).Line.Weight = 0.75
oDoc.InlineShapes(i).Line.Transparency = 0#
oDoc.InlineShapes(i).Line.Visible = False
oDoc.InlineShapes(i).LockAspectRatio = True
oDoc.InlineShapes(i).Height = 200
oDoc.InlineShapes(i).Width = 200
oDoc.InlineShapes(i).PictureFormat.Brightness = 0.5
oDoc.InlineShapes(i).PictureFormat.Contrast = 0.5
oDoc.InlineShapes(i).PictureFormat.CropLeft = 0#
oDoc.InlineShapes(i).PictureFormat.CropRight = 0#
oDoc.InlineShapes(i).PictureFormat.CropTop = 0#
oDoc.InlineShapes(i).PictureFormat.CropBottom = 0#
Next
'clear memory
Set oDummy = Nothing
Set oDoc = Nothing
Set oWord = Nothing
End Sub ----------------------------------------
~~ Code tags added by Oorang
The problem is that i only can insert 2 images, but i want insert 400 images in a directory, i have to read the names automatically and insert this...
Any info appreciated... Thanks
Ps: Excuse for me english.
I'm thinking in a program that insert pics into a Word document and manipulating them. I am new to this myself and need to do something similar. In this case, I want to insert multiple pics into a document, but I WOULD LIKE INSERT A COMPLETE DIRECTORY OF PICS and then scale each one to some size. I then want to print the document.
I am looking others codes and I have finding this:
----------------------------------------------
Sub pega_fotos()
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oDummy As Word.InlineShape
Dim i As Long
Set oWord = New Word.Application
Set oDoc = oWord.Documents.Open(FileName:="C:\blank.doc")
oWord.Visible = True
' insert 2 picture files (bitmaps)
Set oDummy = oDoc.InlineShapes.AddPicture(FileName:="Z:\COGNODATA\Proyectos\BCOP - Funcional Datamart Marketing\An?lisis\An?lisis Descriptivos\AUDITOR?A\BDMI_MUNI2\fig_BDMI_MUNI2_x0x5BEMPRESAS_CARACTE RISTICAS_TIPO_ACTIVOS_TOT0x5D.jpg", _
LinkToFile:=False, SaveWithDocument:=True)
Set oDummy = oDoc.InlineShapes.AddPicture(FileName:="Z:\COGNODATA\Proyectos\BCOP - Funcional Datamart Marketing\An?lisis\An?lisis Descriptivos\AUDITOR?A\BDMI_MUNI2\fig_BDMI_MUNI2_x0x5BEMPRESAS_CARACTE RISTICAS_TIPO_AGRARIO_POR0x5D.jpg", _
LinkToFile:=False, SaveWithDocument:=True)
' insert n picture files (bitmaps)
For i = 1 To oDoc.InlineShapes.Count
' scale it
oDoc.InlineShapes(i).Fill.Visible = False
oDoc.InlineShapes(i).Fill.Transparency = 0#
oDoc.InlineShapes(i).Line.Weight = 0.75
oDoc.InlineShapes(i).Line.Transparency = 0#
oDoc.InlineShapes(i).Line.Visible = False
oDoc.InlineShapes(i).LockAspectRatio = True
oDoc.InlineShapes(i).Height = 200
oDoc.InlineShapes(i).Width = 200
oDoc.InlineShapes(i).PictureFormat.Brightness = 0.5
oDoc.InlineShapes(i).PictureFormat.Contrast = 0.5
oDoc.InlineShapes(i).PictureFormat.CropLeft = 0#
oDoc.InlineShapes(i).PictureFormat.CropRight = 0#
oDoc.InlineShapes(i).PictureFormat.CropTop = 0#
oDoc.InlineShapes(i).PictureFormat.CropBottom = 0#
Next
'clear memory
Set oDummy = Nothing
Set oDoc = Nothing
Set oWord = Nothing
End Sub ----------------------------------------
~~ Code tags added by Oorang
The problem is that i only can insert 2 images, but i want insert 400 images in a directory, i have to read the names automatically and insert this...
Any info appreciated... Thanks
Ps: Excuse for me english.