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 1, 2
   Home -> Office -> Drawing Graphics RSS
Next:  Inserting pictures into Word from My Pictures I g..  
Author Message
David

External


Since: Mar 08, 2006
Posts: 465



(Msg. 1) Posted: Wed Jul 09, 2008 1:58 pm
Post subject: AutoCaption With the Filename of the Image
Archived from groups: microsoft>public>word>drawing>graphics (more info?)

(The real "meat" of my question is in the last paragraph, so please skip
ahead to it if you don't want to read all of this)

I'm currently working on a document that will use a lot of figures. At this
point I'm ready to start inserting the figures and I've been trying to figure
out the most efficient way to do this. What I've tried so far is to create a
Building Block called InsertFigure that contains two other Content Controls;
Picture and a custom InsertFigureAutoCaption control that automatically
numbers the figure and prompts the user to give a title for the caption. So
when I insert a figure using the InsertFigure QuickPart, a dialogue box comes
up prompting the user for the title, and when entered a properly labeled
placeholder comes up with all the correct formatting and the only thing I
have to do is click Change Picture and boom, exactly what I want. Well,
almost. There are a few problems.

When I created the Building Block I wasn't sure of the size I wanted for the
image, so all the figures are the same, too-small size. I want to make them
larger now and the only way I've found to do that is to go through 1 by 1. I
should also mention that I want them all the same size and I did some
searching for a way to easily resize all the images at once and found a macro
that someone had coded. I tried it and it screwed a lot of stuff up. So I
ditched that.

Another problem is that I don't like the Picture border I originally chose
for the Building Block and want to change it. Inside of the InsertFigure
building block I formatted the Picture content control to behave according to
the Picture style. I though I'd want a fancy Word 2007 Picture border and
didn't want to use a dull Word 2003 Paragraph border. Well my tastes have
changed and found that it not only looks better but is much easier to change
if I use the Picture style to control the Picture border. I guess I'm
wondering how can I change all of the InsertFigure bulding blocks I've
inserted to completely get rid of the Picture formatting border?

Now this is what I really want to know... After doing some searching I see
that it's possible to "mail merge" images into a document. So this got me
thinking: Is it possible to create some sort of AutoText (or something of the
like) entry and use field codes to insert an image from a particular database
or more preferably a common folder? The images would have to be inserted in
a particular order from the top of the document to the bottom. If the mail
merge is too complicated or not possible, then is it possible to create a
custom Building Block to insert an image with a field code just below it so
that the field code automatically creates a caption that gives the figure
number AND the filename of the image (without the path or the .jpg
extension). For instance I'd like to create a folder with all of the images
I'm going to use that have a filename similar to "2.4 - Picture of a
Cat.jpg". If I use a custom QuickPart, say "InsertFigure," then I'd want the
image to come up with a caption below it that says, "Figure 2.4 - Picture of
a Cat."

--Any suggestions, ideas, experiences, etc, is certainly appreciated. Sorry
for "rambling." Thanks in advance.
Back to top
Login to vote
David

External


Since: Mar 08, 2006
Posts: 465



(Msg. 2) Posted: Wed Jul 09, 2008 2:16 pm
Post subject: RE: AutoCaption With the Filename of the Image [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I am using Word 2007 by the way.
Back to top
Login to vote
Suzanne S. Barnhill

External


Since: Sep 26, 2003
Posts: 19458



(Msg. 3) Posted: Wed Jul 09, 2008 5:13 pm
Post subject: Re: AutoCaption With the Filename of the Image [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Yeah, your reference to Building Blocks gave that away. <g>

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

"David" <David.DeleteThis@discussions.microsoft.com> wrote in message
news:FB1DD05B-5E06-4148-9C24-E95C8CEC22FC@microsoft.com...
>I am using Word 2007 by the way.
>
Back to top
Login to vote
Doug Robbins - Word MVP

External


Since: Jul 14, 2006
Posts: 4293



(Msg. 4) Posted: Thu Jul 10, 2008 3:04 am
Post subject: Re: AutoCaption With the Filename of the Image [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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...
> (The real "meat" of my question is in the last paragraph, so please skip
> ahead to it if you don't want to read all of this)
>
> I'm currently working on a document that will use a lot of figures. At
> this
> point I'm ready to start inserting the figures and I've been trying to
> figure
> out the most efficient way to do this. What I've tried so far is to
> create a
> Building Block called InsertFigure that contains two other Content
> Controls;
> Picture and a custom InsertFigureAutoCaption control that automatically
> numbers the figure and prompts the user to give a title for the caption.
> So
> when I insert a figure using the InsertFigure QuickPart, a dialogue box
> comes
> up prompting the user for the title, and when entered a properly labeled
> placeholder comes up with all the correct formatting and the only thing I
> have to do is click Change Picture and boom, exactly what I want. Well,
> almost. There are a few problems.
>
> When I created the Building Block I wasn't sure of the size I wanted for
> the
> image, so all the figures are the same, too-small size. I want to make
> them
> larger now and the only way I've found to do that is to go through 1 by 1.
> I
> should also mention that I want them all the same size and I did some
> searching for a way to easily resize all the images at once and found a
> macro
> that someone had coded. I tried it and it screwed a lot of stuff up. So
> I
> ditched that.
>
> Another problem is that I don't like the Picture border I originally chose
> for the Building Block and want to change it. Inside of the InsertFigure
> building block I formatted the Picture content control to behave according
> to
> the Picture style. I though I'd want a fancy Word 2007 Picture border and
> didn't want to use a dull Word 2003 Paragraph border. Well my tastes have
> changed and found that it not only looks better but is much easier to
> change
> if I use the Picture style to control the Picture border. I guess I'm
> wondering how can I change all of the InsertFigure bulding blocks I've
> inserted to completely get rid of the Picture formatting border?
>
> Now this is what I really want to know... After doing some searching I see
> that it's possible to "mail merge" images into a document. So this got me
> thinking: Is it possible to create some sort of AutoText (or something of
> the
> like) entry and use field codes to insert an image from a particular
> database
> or more preferably a common folder? The images would have to be inserted
> in
> a particular order from the top of the document to the bottom. If the
> mail
> merge is too complicated or not possible, then is it possible to create a
> custom Building Block to insert an image with a field code just below it
> so
> that the field code automatically creates a caption that gives the figure
> number AND the filename of the image (without the path or the .jpg
> extension). For instance I'd like to create a folder with all of the
> images
> I'm going to use that have a filename similar to "2.4 - Picture of a
> Cat.jpg". If I use a custom QuickPart, say "InsertFigure," then I'd want
> the
> image to come up with a caption below it that says, "Figure 2.4 - Picture
> of
> a Cat."
>
> --Any suggestions, ideas, experiences, etc, is certainly appreciated.
> Sorry
> for "rambling." Thanks in advance.
Back to top
Login to vote
David Williams

External


Since: Oct 11, 2009
Posts: 2



(Msg. 5) Posted: Sun Oct 11, 2009 12:22 pm
Post subject: Filename as caption [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.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-63...60096a7
Back to top
Login to vote
David Williams

External


Since: Oct 11, 2009
Posts: 2



(Msg. 6) Posted: Sun Oct 11, 2009 12:25 pm
Post subject: Filename as caption [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi Doug
Thanks for that - works a treat.
How would I modify it to apply to deal with, say, 20 pictures at the same time?

You 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
Delegates to the Event
http://www.eggheadcafe.com/tutorials/aspnet/0fa76661-00cb-4777-810a-6c...ed2ca82
Back to top
Login to vote
Doug Robbins - Word MVP

External


Since: Jul 14, 2006
Posts: 4293



(Msg. 7) Posted: Mon Oct 12, 2009 6:05 am
Post subject: Re: Filename as caption [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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 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-63...60096a7
Back to top
Login to vote
Chad Sowald

External


Since: Oct 13, 2009
Posts: 2



(Msg. 8) Posted: Tue Oct 13, 2009 11:22 am
Post subject: Re: Filename as caption [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> Drawing Graphics All times are: Eastern Time (US & Canada) (change)
Goto page 1, 2
Page 1 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