Macro in publisher

S

Stella

I am trying to find out how to insert a picture from a file into a macro. I
cannt find much in the help bar nor in literature nor in the five lessons on
how to write macros. So I am lost. I need to write a simple macro that insert
a picture from file (or fills an empty picture frame). How can I do this?
 
E

Ed Bennett

Stella said:
I am trying to find out how to insert a picture from a file into a macro. I
cannt find much in the help bar nor in literature nor in the five lessons on
how to write macros. So I am lost. I need to write a simple macro that insert
a picture from file (or fills an empty picture frame). How can I do this?

(Page Object).Shapes.AddPicture?
 
S

Stella

I tried two hours on this today but do get errors

Sub first()
Dim page As page
Set page.Shapes.AddPicture"E:\picture1.jpg"

what is wrong with giving the path to the picture?
Thanks
 
E

Ed Bennett

Stella said:
I tried two hours on this today but do get errors

Sub first()
Dim page As page
Set page.Shapes.AddPicture"E:\picture1.jpg"

what is wrong with giving the path to the picture?

a) "page" is the name of the Page data type, and so is reserved and
cannot be used for a variable name.

b) You haven't ended your sub.

c) "Set" is used to assign an object to a variable. For example, if your
Page variable were called "aPage", then

Set aPage = ThisDocument.Pages(1)

would set aPage to be the first page of the current document, and

Set aPage = ThisDocument.ActiveView.ActivePage

would set aPage to be the active page.

d) "Set" is not used for executing methods. The AddPicture method is a
method, and so goes on a line of its own; unless you want to assign the
resulting shape to a new variable. For example

aPage.Shapes.AddPicture "e:\Picture1.jpg"

or

Dim aShape As Shape
Set aShape = aPage.Shapes.AddPicture("e:\Picture1.jpg")

(note that when the method comes after an assignment, the arguments are
bracketed; otherwise, they are not)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top