Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2005

Tip: Looking for answers? Try searching our database.

insert images from a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marco - 28 Dec 2005 11:33 GMT
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
Cindy M  -WordMVP- - 28 Dec 2005 15:01 GMT
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 :-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.