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 / July 2007

Tip: Looking for answers? Try searching our database.

Recording Macro's  Office 2007

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roger Stenson - 08 Jul 2007 07:14 GMT
Hi
I need to record a macro covering the insertion of a picture.
This worked ok basically when I tried it. However  in the Format menu when I
adjusted the height and the size of the picture these acts were not recorded
in the macro.
Is there a code sequence that I could insert in the macro that would resize
the pictures to standard dimensions
Yours with thanks in anticipation

Roger Stenson
Doug Robbins - Word MVP - 11 Jul 2007 04:18 GMT
Here's some code that inserts a picture into a cell of a table in the first
page header of a document and then adjusts the size of that picture:

'Insert Logo on Title Page
       myDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range.Tables(1).Cell(1,
1).Range.InlineShapes.AddPicture Filename:=txtLargeLogoPath
'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

Signature

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

> Hi
> I need to record a macro covering the insertion of a picture.
[quoted text clipped - 6 lines]
>
> Roger Stenson
Roger Stenson - 20 Jul 2007 11:16 GMT
Thanks very much for your help ~Worked a treat
Roger Stenson
> Here's some code that inserts a picture into a cell of a table in the
> first page header of a document and then adjusts the size of that picture:
[quoted text clipped - 43 lines]
>>
>> Roger Stenson
 
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.