Sizing picture with macro 
Author Message
 Sizing picture with macro

Hello,

I am a newbie in VB and need help for a macro. I'd like to
include a picture automatically on event OpenDocument in a
word file. This picture must be inserted in the body of
the current page with a max width of 17cm (the ratio of
resizing must be the same for height and width of the
picture).

Thanks for your help
Regards

JBC



Sat, 02 Jul 2005 21:18:06 GMT  
 Sizing picture with macro
Hello JBC

Use this to include a picture from your hard drive:

        Selection.InlineShapes.AddPicture FileName:= _
            "[File Path]\[File Name].gif", LinkToFile:=False, _
            SaveWithDocument:=True

This sizes it, although you might have to reselect the image first:

    Selection.InlineShapes(1).Height = 73.4                'Set picture size
    Selection.InlineShapes(1).Width = 89.55

I can't quite remember if the values are centimetre values or not. I don't
think they are. Play with this and see how altering the height and width
values changes your image's shape.

Hope it helps.

Best wishes
Peter

Kessler Associates

W: http://homepages.tesco.net/~plk33/plk33/index.htm


Quote:
> Hello,

> I am a newbie in VB and need help for a macro. I'd like to
> include a picture automatically on event OpenDocument in a
> word file. This picture must be inserted in the body of
> the current page with a max width of 17cm (the ratio of
> resizing must be the same for height and width of the
> picture).

> Thanks for your help
> Regards

> JBC



Sat, 02 Jul 2005 23:23:26 GMT  
 Sizing picture with macro
Hello Peter

Thanks for the answer... it works well, but I have still
two questions :

- the function AddPicture adds a picture and I am looking
for a function that refreshes the link to the picture file
instead of adding a new picture each time I open the
document. A function that deletes the old picture before
the function AddPicture could be a solution too.

- the picture I'd like to insert is in a web directory
(http://[server name]/[web directory]/[file].wmf) and I
don't know how to fix it...

Tahnks for your help
Best regards
JBC

Quote:
>-----Original Message-----
>Hello JBC

>Use this to include a picture from your hard drive:

>        Selection.InlineShapes.AddPicture FileName:= _
>            "[File Path]\[File Name].gif",

LinkToFile:=False, _
Quote:
>            SaveWithDocument:=True

>This sizes it, although you might have to reselect the
image first:

>    Selection.InlineShapes(1).Height =

73.4                'Set picture size
Quote:
>    Selection.InlineShapes(1).Width = 89.55

>I can't quite remember if the values are centimetre

values or not. I don't
Quote:
>think they are. Play with this and see how altering the
height and width
>values changes your image's shape.

>Hope it helps.

>Best wishes
>Peter

>Kessler Associates

>W: http://homepages.tesco.net/~plk33/plk33/index.htm



>> Hello,

>> I am a newbie in VB and need help for a macro. I'd like
to
>> include a picture automatically on event OpenDocument
in a
>> word file. This picture must be inserted in the body of
>> the current page with a max width of 17cm (the ratio of
>> resizing must be the same for height and width of the
>> picture).

>> Thanks for your help
>> Regards

>> JBC

>.



Sun, 03 Jul 2005 00:21:22 GMT  
 Sizing picture with macro

Hello JBC

The path for a server where I am uses the server's address:
"\\FILESERVER\[sub folders]". I'm able to check on what the address is by
browsing in Windows Explorer so that the path shows up in the window's top
bar. If you're still not sure, do you have any IT people there to get the
path details from?

Why does your picture need to be refreshed when the document is opened? The
document should still contain the picture that you inserted previously, so
unless that picture is altered regularly I'm not sure I see the need to
refresh it. Still, an easy way of being sure you have the latest image is to
have OpenDocument auto-insert your picture from the server and resize and
position it correctly. Would that work for you?

Best wishes
Peter

Kessler Associates

W: http://homepages.tesco.net/~plk33/plk33/index.htm


Quote:
> Hello Peter

> Thanks for the answer... it works well, but I have still
> two questions :

> - the function AddPicture adds a picture and I am looking
> for a function that refreshes the link to the picture file
> instead of adding a new picture each time I open the
> document. A function that deletes the old picture before
> the function AddPicture could be a solution too.

> - the picture I'd like to insert is in a web directory
> (http://[server name]/[web directory]/[file].wmf) and I
> don't know how to fix it...

> Tahnks for your help
> Best regards
> JBC



Mon, 04 Jul 2005 00:32:46 GMT  
 Sizing picture with macro

Hello Peter,

Thanks again...I now manage to get the file from a
server's adress.
The picture that I need to load in my document is
regularly modified (in a batch mode), that's why I want to
update the picture rather than adding a new one each time
the document is opened.
Thanks for your help

Best regards

JBC

Quote:
>-----Original Message-----
>Hello JBC

>The path for a server where I am uses the server's
address:
>"\\FILESERVER\[sub folders]". I'm able to check on what
the address is by
>browsing in Windows Explorer so that the path shows up in
the window's top
>bar. If you're still not sure, do you have any IT people
there to get the
>path details from?

>Why does your picture need to be refreshed when the

document is opened? The
Quote:
>document should still contain the picture that you

inserted previously, so
Quote:
>unless that picture is altered regularly I'm not sure I
see the need to
>refresh it. Still, an easy way of being sure you have the
latest image is to
>have OpenDocument auto-insert your picture from the

server and resize and
Quote:
>position it correctly. Would that work for you?

>Best wishes
>Peter

>Kessler Associates

>W: http://homepages.tesco.net/~plk33/plk33/index.htm



>> Hello Peter

>> Thanks for the answer... it works well, but I have still
>> two questions :

>> - the function AddPicture adds a picture and I am
looking
>> for a function that refreshes the link to the picture
file
>> instead of adding a new picture each time I open the
>> document. A function that deletes the old picture before
>> the function AddPicture could be a solution too.

>> - the picture I'd like to insert is in a web directory
>> (http://[server name]/[web directory]/[file].wmf) and I
>> don't know how to fix it...

>> Tahnks for your help
>> Best regards
>> JBC

>.



Mon, 04 Jul 2005 18:20:06 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Picture size on Form for different monitor size

2. Size a picture to a picture box?

3. Word macro containing a change of font size

4. controling font size in footer macro

5. Font Size macro toolbar buttons...

6. Macro to customize the size of Word controls ?

7. Minimizing Macro Size / Distribution

8. Macro to change text, also changes font size.

9. Font Size macro toolbar buttons...

10. Saving Excel spreadsheet with VB macro size increases

11. Changing Paper Size in Excel Visual Basic Macro

12. How to get a picture size in pixels ?

 

 
Powered by phpBB® Forum Software