insert images from a form

M

Marco

i'am now using the code below to insert images one by one in my word
document change width, height and add a border
But i want to make a form where i can select al pictures in one folder
and select which one of them should be used and formatted by the code
below.
First problem is how to use "With Dialogs(wdDialogInsertPicture).Show"
and store the path to the selected file in a variable?
Second is it possible to show a preview image of all the files from
that folder.

I'am working with word 2000


Sub Linktopicture()
With Dialogs(wdDialogInsertPicture)
.Show
End With

Dim mypicw As InlineShape
For Each mypicw In ActiveDocument.InlineShapes
mypicw.Select
X = mypicw.Width
If X > 302 Then
mypicw.Width = 302
End If
Next

Dim mypich As InlineShape
For Each mypich In ActiveDocument.InlineShapes
mypich.Select
Y = mypich.Height
If Y > 227 Then
mypich.Height = 227
End If
Next

With Selection.InlineShapes(0)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
.Color = wdColorAutomatic
End With
.Borders.Shadow = False
'Selection.Collapse
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.TypeParagraph
Selection.TypeParagraph

End With



End Sub

--
 
C

Cindy M -WordMVP-

Hi Marco,
First problem is how to use "With Dialogs(wdDialogInsertPicture).Show"
and store the path to the selected file in a variable?
Don't use "Show", use "Display". And test the return value this gives,
in order to find out whether the user cancelled:

With Dialogs(wdDialogInsertPicture)
If .Display <> 0 Then
sFileName = .Name
End if
End With
Second is it possible to show a preview image of all the files from
that folder.
I don't really have a good answer for this one. Later versions of Word
have a "thumbnails" view for the dialog box. The UserForms in Office
have an IMAGE control and you should be able to use that to show an
individual picture (like if you load a list box with all the files from
the folder, then click on one at a time, code behind the form can load
that into the image control). Does that sound like what you're
interested in?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top