Re: Re-size specific images in a doc by Doug
Doug
Fri Nov 07 20:38:32 CST 2003
Hi Delia,
All of the following needs to be one line of code
oheight =
myDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range.Tables(1).Cell(1,
1).Range.InlineShapes(1).Height
and it assumes that the image is in the first cell on thte first row of the
first table in the header. If that is not where it is, you will have to
modify the code so that it refers to your image location.
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Delia" <delia_rusu@hotmail.com> wrote in message
news:05bb01c3a540$de89ab00$a001280a@phx.gbl...
> Hi Doug and thanks. Sorry to bother you again.
>
> I had already done that, but when running the macro, it
> stops at the first line (oheight=...) with an error (Run-
> time error 5491 "The requested member of the collection
> does not exist.")
>
> I must be doing something wrong...
>
> >-----Original Message-----
> >Hi Delia
> >
> >Dim myDoc as Document
> >Set myDoc = ActiveDocument
> >
> >then use the rest of the code.
> >
> >--
> >Please post any further questions or followup to the
> newsgroups for the
> >benefit of others who may be interested. Unsolicited
> questions forwarded
> >directly to me will only be answered on a paid consulting
> basis.
> >
> >Hope this helps
> >Doug Robbins - Word MVP
> >"Delia" <delia_rusu@hotmail.com> wrote in message
> >news:0d8101c3a477$e53b5440$a301280a@phx.gbl...
> >> Thanks, Doug.
> >>
> >> How can I tell the macro to apply the procedure to the
> >> opened document instead of actually specifying the
> >> document name? ActiveDocument does not work :(.
> >>
> >> I want to be able to run this macro from a document,
> >> before performing other tasks, rather than on a document
> >> in the background.
> >>
> >> Thanks again.
> >>
> >>
> >> >-----Original Message-----
> >> >Hi Delia,
> >> >
> >> >Here's a bit of code from one of my projects that
> should
> >> help you:
> >> >
> >> >'Adjust size of logo to match avalable space
> >> > oheight =
> >> >myDoc.Sections(1).Headers
> >> (wdHeaderFooterPrimary).Range.Tables(1).Cell(1,
> >> >1).Range.InlineShapes(1).Height
> >> > owidth =
> >> >myDoc.Sections(1).Headers
> >> (wdHeaderFooterPrimary).Range.Tables(1).Cell(1,
> >> >1).Range.InlineShapes(1).Width
> >> > If oheight < InchesToPoints(2) Then
> >> > With
> >> >myDoc.Sections(1).Headers
> >> (wdHeaderFooterPrimary).Range.Tables(1).Cell(1,
> >> >1).Range.InlineShapes(1)
> >> > .Height = InchesToPoints(2)
> >> > .Width = owidth * InchesToPoints
> (2) /
> >> oheight
> >> > End With
> >> > End If
> >> > oheight =
> >> >myDoc.Sections(1).Headers
> >> (wdHeaderFooterPrimary).Range.Tables(1).Cell(1,
> >> >1).Range.InlineShapes(1).Height
> >> > owidth =
> >> >myDoc.Sections(1).Headers
> >> (wdHeaderFooterPrimary).Range.Tables(1).Cell(1,
> >> >1).Range.InlineShapes(1).Width
> >> > If owidth > InchesToPoints(2.85) Then
> >> > With
> >> >myDoc.Sections(1).Headers
> >> (wdHeaderFooterPrimary).Range.Tables(1).Cell(1,
> >> >1).Range.InlineShapes(1)
> >> > .Width = InchesToPoints(2.85)
> >> > .Height = oheight * InchesToPoints
> >> (2.85) / owidth
> >> > End With
> >> > End If
> >> >
> >> >
> >> >--
> >> >Please post any further questions or followup to the
> >> newsgroups for the
> >> >benefit of others who may be interested. Unsolicited
> >> questions forwarded
> >> >directly to me will only be answered on a paid
> consulting
> >> basis.
> >> >
> >> >Hope this helps
> >> >Doug Robbins - Word MVP
> >> >"Delia" <delia_rusu@hotmail.com> wrote in message
> >> >news:02a501c3a3e1$40eb7e10$a501280a@phx.gbl...
> >> >> I'm trying to write a macro that would search through
> >> all
> >> >> the images in a document, check if they have a
> specific
> >> >> width (> than 6", let's say), and re-size them to a
> >> width
> >> >> of 6", while the height changes proportionally.
> >> >>
> >> >> In other words, fix the figures that spill over the
> page
> >> >> margins. I also have other figures in the document
> (that
> >> >> have a size<6") that I don't want to touch.
> >> >>
> >> >> Can this be made? Thanks for any help.
> >> >
> >> >
> >> >.
> >> >
> >
> >
> >.
> >