Need help with powerpoint footer replacement with C# Office Automation

C

CodeHulk

This is an office automation project.

I am currently working on a document control project tracking
powerpoint, word, and excel documents. The documents are required to
have a specific style of footer as mandated by an organization that has
given us certification. The style looks as follows:

<UserDefinedInfo> <UserDefinedInfo>
<Date> Page <page> of
<Pages>

If there is a footer the data needs to be erased and then replaced with
a footer that looks like the one above. If there isn't a footer then
one needs to be added and include the above information.

The word and excel documents went well and work fine. However, seeing
as there is no real standardization between how the products work. I'm
having a lot of trouble. The biggest is we can assume nothing about
the format of the document. We can't assume slide size, footer
location, whehter or not the footer is present or whether or not it has
text in. I could find a lot of information on such activites in word
and excel but absolutely nothing in Powerpoint. I've performed the
task as a macro and then converted the VBA to C#, however, the VBA that
gets spit out is specific to the document the macro was recorded in.

The boss was very adamant about this being possible and done in this
exact away, however, he could offer no input as to how.

If anybody can give me a hand or point me in some type of direction
with this I would much appreciate it.

Thanks,
~Justin
 
S

Steve Rindsberg

Determining whether one of your own footers is there or not should be simple.
You'd only need to give the shape or shapes unique name(s) and/or tags so you
can get a reference to them later.

The problem is grabbing an existing footer that might have been created by
someone else. Again, grabbing the PPT supplied one shouldn't be too hard but
beyond that, how do you decide what constitutes a footer?

Is it any text within a certain area? If so, you could iterate through all the
shapes on the slide (or master) and test their .Top and .Left properties
against some target values.
 
C

CodeHulk

See, thats the problem I'm having is that I am not allowed to assume
anything about it. So though there will be a unique name I have no way
of knowing exactly where it is. The Top and Left values I could
probably set up to work for the majority of causes however it is not
general enough to work for all.

I originally was going to just check if a footer exists...if it does
delete it and create my own footer to insert it. However, issues such
as the footer size and where it should be placed came up. I could
compute the values given the restraints of the current slide. But
there are a ton of other problems that come up to, such as making sure
my footer doesn't cover up something that is already there.

I knew I shouldn't have got into computers. :)

~Justin
 
S

Steve Rindsberg

See, thats the problem I'm having is that I am not allowed to assume
anything about it.

I don't see how you can do anything w/o making at least some assumptions, otherwise
any bit of text on the screen *might* be a footer.

But you say there's a unique name? The footer shape, that is? If so, it'd be
quite easy to locate.
 
C

CodeHulk

I don't see how you can do anything w/o making at least some assumptions, otherwise
any bit of text on the screen *might* be a footer.

This was my point exactly. :)
But you say there's a unique name? The footer shape, that is? If so, it'd be
quite easy to locate.

I am not an amazing powerpoint guru but every object underneath should
have a unique name associated with it. But it isn't known necessarily
what that name is. This is all just speculation I haven't been able
to find a lot of info on it. The shapes are stored as a collection (at
least that is how you access them through code) and they have a name
associated with them such as "Rectange 4" and such. I don't know how
the names are set up or anything like that. This is just the best
estimates I could come up with. I'm at wits end with this stuff. The
worst part is the only reason the documents are in powerpoint instead
of word or even better just excel like they should be is because the
people who did them were more comfortable with Powerpoint. WHO ENTERS
FORM DATA IN POWERPOINT!?!?!?!? :) Man this job would be great if it
wasn't for the users. lol j/k Thanks for the help Steve. I think I'm
just going to chalk this up as a lost cause.
 
S

Steve Rindsberg

This was my point exactly. :)

Sounds like it's time to flatten the boss' pointy hair with the Reality Bat then.
I am not an amazing powerpoint guru but every object underneath should
have a unique name associated with it. But it isn't known necessarily
what that name is. This is all just speculation I haven't been able
to find a lot of info on it.

Ah, well, yes. Each shape has a name and on a good day, the names are unique (though
PowerPoint may sometimes create more than one shape with the same name - something to
be aware and beware of)

Your understanding is correct. You can take it a few steps further and test each shape
to determine what type of shape it is, whether it has text and so on, but that still
just narrows it down to the shapes that have text. Unless you can find some other
unique feature (position, font, size, color, some bit of identifying text) you can test
for, there'll be no way to distinguish footnotes (or at least text that's been placed
on the slide to look like a footnote) from other text.
 

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