WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

AutoCaption With the Filename of the Image

 
Goto page Previous  1, 2
   Home -> Office -> Drawing Graphics RSS
Next:  Inserting pictures into Word from My Pictures I g..  
Author Message
Chad Sowald

External


Since: Oct 13, 2009
Posts: 2



(Msg. 9) Posted: Tue Oct 13, 2009 11:25 am
Post subject: Re: Filename as caption [Login to view extended thread Info.]
Archived from groups: microsoft>public>word>drawing>graphics (more info?)

On Oct 13, 2:22 pm, Chad Sowald <chadsow... DeleteThis @gmail.com> wrote:
> On Oct 12, 5:49 am, "Doug Robbins - Word MVP"
>
>
>
>
>
> <d... DeleteThis @REMOVECAPSmvps.org> wrote:
> > The following code will display a dialog in which you can select the folder
> > that contains the picture files and then it will insert each of the pictures
> > into a document with the filename of each following the picture
>
> > Dim myFile As String
> > Dim PathToUse As String
> > Dim myDoc As Document
> > Dim myrange As Range
> > 'Select the folder that contains the files
> > With Dialogs(wdDialogCopyFile)
> >     If .Display <> 0 Then
> >         PathToUse = .Directory
> >     Else
> >         MsgBox "Cancelled by User"
> >         Exit Sub
> >     End If
> > End With
> > 'Close all open documents before beginning
> > Documents.Close SaveChanges:=wdPromptToSaveChanges
> > 'Get the new title to be used for each document
> > Documents.Add
> > myFile = Dir(PathToUse & "*.*")
> > While myFile <> ""
> >     With ActiveDocument
> >         Set myrange = .Range
> >         myrange.Collapse wdCollapseEnd
> >         .InlineShapes.AddPicture PathToUse & myFile, , , myrange
> >         Set myrange = .Range
> >         myrange.Collapse wdCollapseEnd
> >         myrange.InsertAfter vbCr & myFile & vbCr
> >     End With
> >     myFile = Dir()
> > Wend
>
> > --
> > Hope this helps.
>
> > Please reply to the newsgroup unless you wish to avail yourself of my
> > services on a paid consulting basis.
>
> > Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>
> > "David Williams" wrote in messagenews:20091011152213zzdave@gmail.com...
> > > Thanks Doug, that worked really well for me.
>
> > > How would I modify it so that it worked whilst inserting say 20 pictures
> > > at a time. When I try this code it only puts one caption at the bottom.
>
> > > Your help is appreciated, thanks
>
> > > Dave
>
> > > Doug Robbins - Word MVP wrote:
>
> > > Re: AutoCaption With the Filename of the Image
> > > 09-Jul-08
>
> > > I posted this for someone else the other day:
>
> > > Running the following macro will allow you to select the picture that you
> > > want to insert, then it inserts the picture and the name of the file after
> > > the picture in a paragraph that is center aligned:
>
> > >    Dim txtPhotoPath as String
> > >    With Dialogs(wdDialogInsertPicture)
> > >        If .Show Then
> > >            txtPhotoPath = WordBasic.FilenameInfo$(.Name, 0)
> > >        End If
> > >        Selection.InsertAfter vbCr & txtPhotoPath
> > >        Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
> > >    End With
>
> > > You could modify it so that it also inserted a Figure number.
>
> > > --
> > > Hope this helps.
>
> > > Please reply to the newsgroup unless you wish to avail yourself of my
> > > services on a paid consulting basis.
>
> > > Doug Robbins - Word MVP
>
> > > "David" <Da... DeleteThis @discussions.microsoft.com> wrote in message
> > >news:B86493C0-452E-4BE3-9442-407A2C2B2485@microsoft.com...
>
> > > EggHeadCafe - Software Developer Portal of Choice
> > > Book Review: C# 3.0 Cookbook [O'Reilly]
> > >http://www.eggheadcafe.com/tutorials/aspnet/59386eb3-3049-46a7-8f07-6....
>
> Hi Doug.  I get an error on the line:   myFile = Dir(PathToUse &
> "*.*")         with an error message of "Bad file name or number"..
>
> Do you know what would be wrong?  I haven't modified your code at all.

Hey Doug. Nevermind, turns out the file path was too long. I moved
the images to another directory (closer to the root) and it worked
great. Thanks!
Back to top
Login to vote
DP

External


Since: May 25, 2006
Posts: 24



(Msg. 10) Posted: Mon Nov 30, 2009 4:39 pm
Post subject: Re: Filename as caption [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Is there a way to control the order in which the images will be inserted?
(i.e. sorted by filename, date modified, or something else)

"Doug Robbins - Word MVP" wrote:

> The following code will display a dialog in which you can select the folder
> that contains the picture files and then it will insert each of the pictures
> into a document with the filename of each following the picture
>
> Dim myFile As String
> Dim PathToUse As String
> Dim myDoc As Document
> Dim myrange As Range
> 'Select the folder that contains the files
> With Dialogs(wdDialogCopyFile)
> If .Display <> 0 Then
> PathToUse = .Directory
> Else
> MsgBox "Cancelled by User"
> Exit Sub
> End If
> End With
> 'Close all open documents before beginning
> Documents.Close SaveChanges:=wdPromptToSaveChanges
> 'Get the new title to be used for each document
> Documents.Add
> myFile = Dir(PathToUse & "*.*")
> While myFile <> ""
> With ActiveDocument
> Set myrange = .Range
> myrange.Collapse wdCollapseEnd
> .InlineShapes.AddPicture PathToUse & myFile, , , myrange
> Set myrange = .Range
> myrange.Collapse wdCollapseEnd
> myrange.InsertAfter vbCr & myFile & vbCr
> End With
> myFile = Dir()
> Wend
>
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
> "David Williams" wrote in message news:20091011152213zzdave@gmail.com...
> > Thanks Doug, that worked really well for me.
> >
> > How would I modify it so that it worked whilst inserting say 20 pictures
> > at a time. When I try this code it only puts one caption at the bottom.
> >
> > Your help is appreciated, thanks
> >
> > Dave
> >
> >
> >
> > Doug Robbins - Word MVP wrote:
> >
> > Re: AutoCaption With the Filename of the Image
> > 09-Jul-08
> >
> > I posted this for someone else the other day:
> >
> > Running the following macro will allow you to select the picture that you
> > want to insert, then it inserts the picture and the name of the file after
> > the picture in a paragraph that is center aligned:
> >
> > Dim txtPhotoPath as String
> > With Dialogs(wdDialogInsertPicture)
> > If .Show Then
> > txtPhotoPath = WordBasic.FilenameInfo$(.Name, 0)
> > End If
> > Selection.InsertAfter vbCr & txtPhotoPath
> > Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
> > End With
> >
> > You could modify it so that it also inserted a Figure number.
> >
> > --
> > Hope this helps.
> >
> > Please reply to the newsgroup unless you wish to avail yourself of my
> > services on a paid consulting basis.
> >
> > Doug Robbins - Word MVP
> >
> > "David" <David.TakeThisOut@discussions.microsoft.com> wrote in message
> > news:B86493C0-452E-4BE3-9442-407A2C2B2485@microsoft.com...
> >
> > EggHeadCafe - Software Developer Portal of Choice
> > Book Review: C# 3.0 Cookbook [O'Reilly]
> > http://www.eggheadcafe.com/tutorials/aspnet/59386eb3-3049-46a7-8f07-63...60096a7
>
>
Back to top
Login to vote
Doug Robbins - Word MVP

External


Since: Jul 14, 2006
Posts: 4340



(Msg. 11) Posted: Mon Nov 30, 2009 11:05 pm
Post subject: Re: Filename as caption [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Use the information in the article
http://word.mvps.org/faqs/MacrosVBA/InsertFileNames.htm to create a list of
the files, sort them into the order that you want and then use that file as
the data source for mailmerge to insert the pictures into a document.

See the "merge in a picture from a database" item on the following page of
fellow MVP Cindy Meister's website:

http://homepage.swissonline.ch/cindymeister/mergfaq1.htm

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

"DP" <DP RemoveThis @discussions.microsoft.com> wrote in message
news:37F12A7F-1E0D-4FD7-A64B-6F6CF8599D10@microsoft.com...
> Is there a way to control the order in which the images will be inserted?
> (i.e. sorted by filename, date modified, or something else)
>
> "Doug Robbins - Word MVP" wrote:
>
>> The following code will display a dialog in which you can select the
>> folder
>> that contains the picture files and then it will insert each of the
>> pictures
>> into a document with the filename of each following the picture
>>
>> Dim myFile As String
>> Dim PathToUse As String
>> Dim myDoc As Document
>> Dim myrange As Range
>> 'Select the folder that contains the files
>> With Dialogs(wdDialogCopyFile)
>> If .Display <> 0 Then
>> PathToUse = .Directory
>> Else
>> MsgBox "Cancelled by User"
>> Exit Sub
>> End If
>> End With
>> 'Close all open documents before beginning
>> Documents.Close SaveChanges:=wdPromptToSaveChanges
>> 'Get the new title to be used for each document
>> Documents.Add
>> myFile = Dir(PathToUse & "*.*")
>> While myFile <> ""
>> With ActiveDocument
>> Set myrange = .Range
>> myrange.Collapse wdCollapseEnd
>> .InlineShapes.AddPicture PathToUse & myFile, , , myrange
>> Set myrange = .Range
>> myrange.Collapse wdCollapseEnd
>> myrange.InsertAfter vbCr & myFile & vbCr
>> End With
>> myFile = Dir()
>> Wend
>>
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>> "David Williams" wrote in message news:20091011152213zzdave@gmail.com...
>> > Thanks Doug, that worked really well for me.
>> >
>> > How would I modify it so that it worked whilst inserting say 20
>> > pictures
>> > at a time. When I try this code it only puts one caption at the bottom.
>> >
>> > Your help is appreciated, thanks
>> >
>> > Dave
>> >
>> >
>> >
>> > Doug Robbins - Word MVP wrote:
>> >
>> > Re: AutoCaption With the Filename of the Image
>> > 09-Jul-08
>> >
>> > I posted this for someone else the other day:
>> >
>> > Running the following macro will allow you to select the picture that
>> > you
>> > want to insert, then it inserts the picture and the name of the file
>> > after
>> > the picture in a paragraph that is center aligned:
>> >
>> > Dim txtPhotoPath as String
>> > With Dialogs(wdDialogInsertPicture)
>> > If .Show Then
>> > txtPhotoPath = WordBasic.FilenameInfo$(.Name, 0)
>> > End If
>> > Selection.InsertAfter vbCr & txtPhotoPath
>> > Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
>> > End With
>> >
>> > You could modify it so that it also inserted a Figure number.
>> >
>> > --
>> > Hope this helps.
>> >
>> > Please reply to the newsgroup unless you wish to avail yourself of my
>> > services on a paid consulting basis.
>> >
>> > Doug Robbins - Word MVP
>> >
>> > "David" <David RemoveThis @discussions.microsoft.com> wrote in message
>> > news:B86493C0-452E-4BE3-9442-407A2C2B2485@microsoft.com...
>> >
>> > EggHeadCafe - Software Developer Portal of Choice
>> > Book Review: C# 3.0 Cookbook [O'Reilly]
>> > http://www.eggheadcafe.com/tutorials/aspnet/59386eb3-3049-46a7-8f07-63...60096a7
>>
>>
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> Drawing Graphics All times are: Eastern Time (US & Canada) (change)
Goto page Previous  1, 2
Page 2 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
  Office
 Office Other
 Security
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET |
  • IT Support