PDA

View Full Version : ActiveX images in new page



Humpty
12-22-2007, 06:33 PM
Hi all,

I am enjoying looking through the forums and was wondering if someone might be able to offer me some help?

I have a Word template that has a header and footer (different on first page) and three images down the R-hand side of the page. My question is: How can I get the images to repeat in a new page??

To complicate the issues, the images are ActiveX images that have additional functionality if clicked. Any help would be hugely appreciated.

Thanks.

Humpty
12-22-2007, 06:55 PM
To simplify (I think!), what I am actually after is something like an 'OnNewPage' event that I can capture to run code to insert the images in the new page. Does such an event exist??

fumei
12-24-2007, 12:01 PM
No, there is no OnNewPage event.

"To complicate the issues, the images are ActiveX images that have additional functionality if clicked. "

Indeed.

1. What do you mean by "ActiveX images "? I have never heard of an ActiveX image. Do you mean an ActiveX control that contains an image?

2. Yes, it would complicate things immensely.

I have to ask...why are you doing this? What is the 'additional functionality"? Why does it have to be on another page? Can this functionality be activated by some other means?

You are going to have to give a much more detailed description. I am not sure what the header reference is about. Is it just because you have it as a different first page? Are these images in the header? It does not quite sound like it, but I am not sure.

Are they InlineShapes - in-line with the paragraph? Or are they Shapes - movable?

What you seem to be asking may, or may not, be possible. What is definitely not possible is any substantive answer based on the information given so far.

Humpty
12-24-2007, 01:01 PM
Thanks for the reply. Much appreciated. Sometimes it's difficult to know exactly what question to ask!

I may have got my terminology mixed up with the 'ActiveX' image. They are image controls rather than just images. The 'additional functionality' is that the images have code that triggers when they are clicked: L click brings up a browse box to select a new image for the control, R click prompts whether the user wants the image removed.

What I would like to happen is that when the text runs onto a second page, new image controls are generated with the same functionality. The header issue kind of confused things. I guess I only mentioned it as the header repeats for new pages and I want the images that are not in the header to do the same thing.

Maybe, as you say, this functionality can be activated by some other means, but as a bit of a novice I feel unsure as to the best way to do it.

Any further pointers appreciated.

Oh, and they are inline shapes; they are images of fixed size and fixed position on the page.

fumei
12-26-2007, 07:25 AM
OK, just to confirm. These are controls placed into the document with the Controls toolbar. Yes?

How are you trapping the left vs right clicks?

I am not sure this may be possible. Can you post a sample document?

Humpty
12-26-2007, 02:33 PM
Thanks for the reply. Good to hear from you again.

I am away from the office at the moment but have quickly removed some of the confidential details from the form and attach it. I am after quite a lot of functionality on this but the crux at the moment is adding the image controls to subsequent pages.

Your assumptions on the images are correct; I am trapping the Click event of the controls.

All rather rough and ready at the moment (I've spent a lot of time going round in circles and not enought time commenting code!) but any help you can offer would be hugely appreciated!!

lucas
12-26-2007, 03:17 PM
Why not insert the new page from a template?

fumei
12-27-2007, 11:27 AM
"Oh, and they are inline shapes; they are images of fixed size and fixed position on the page."

Ummm, no they are most definitely NOT.

They are NOT InlineShapes. They are Shapes. How can you state they are InlineShapes when your own code uses Shapes?????? ActiveDocument.Shapes(strImage).OLEFormat _
.Object.Picture = LoadPicture(strPath)

They are NOT of fixed size and position on the page. They are free floating Shapes.

I find it interesting that you use a ActiveX textbox in the header. Why?

You state: "R click prompts whether the user wants the image removed."

This is not what happens. A right click asks if the user wants the image box deleted. Not the image, but the control itself. Not the same thing. Your code does not, in fact, delete the imagebox. It hides it, sort of. If you click the Design Mode button, you can still grab the control and move it around. You can in fact move it around over the text..blocking any text.

Further, I fail to see the point to this. if the user does "delete" the imagebox, it still exists, is still moveable, but there is NO way for the user to ever use it again. You set it as enabled = false, with no method to get it back.

Why? If you are doing that, why not simply really delete it?

If you "delete" it (as currently coded), then click Design Mode, then left click it again, you get the InsertPicture dialog - but your Hide routine has changed the background.

Further, if you do NOT "delete" it, and use left click to insert an image, then left click again (getting the InsertPicture dialog), but press Cancel, the image control does NOT retain the starting image (which would be proper as there is a cancel...yes?), but removes the image out of the control.

If I have image "Blah", in the control, left click the control and go...oh, crap...wrong control, I meant the OTHER one...press Cancel....don't you think it should leave things alone? Why would cancel mean remove the current image?

Bottom line though is, again, why are you doing this? What exactly is the business case for it?

Regarding the original post on a new page, you still have a problem. Steve's suggestion will not work. This IS a template.

I am going have to say that you can not do what you are asking. It is possible - but not trivial - to create the controls on new pages after the fact. But not automatically, in that if you add text that makes a new page, the controls will be added automatically.

You need to be clear on something. Those ActiveX controls are explicit objects. You have code for each of them.

Sub frmPhoto1_Click()
Sub frmPhoto2_Click()
Sub frmPhoto3_Click()

Any additional controls - on a new page - would also be explicit controls, and would require their own procedure (Sub).

Is there a way around it so that any control clicked would fire something? Yes - sort of, but again, it is not trivial. Yet, there is NO way around the requirement that every control - including any additional ones you possibly created on a new page - needs an explicit Click procedure to do anything.

Even a Copy requires this.

So say you now have a new page, and you copy, say, the first control frmPhoto1. You Paste it into the new page. Yup, there it is. A new control. HOWEVER, its name is frmPhoto11...and guess what???? You have NO code for it. Click events are tied to explicit objects. They fire when THAT object is clicked. No Click event Sub, no firing of a Click event. Makes sense.

The short answer is - as you have it set up, with the functionality you have - no, you will not be able to do this.

The long answer is, yes is possible. However, it would be tricky and I have to ask if it is worth it. How? By determining if there is more than one page. Then adding controls to those pages, and with code, write code for those controls.

Could you please tell me EXACTLY how you put those image controls in your document? Every step, exactly how you did them. Thanks.

Humpty
12-29-2007, 02:22 AM
Thanks for replying once again Gerry; and thanks for such a lengthy response.

There is a lot with this template that I am not happy with and it has been a case of trial and error in getting this far (if this is actually anywhere at all!).

I am wanting to achieve the following:

1) Template with limited fonts and styles with three images down the side
2) Images of fixed size and position (the original template was protected to prevent the images from being moved but I removed the protection to upload it to avoid complications)
3) If the user clicks the image they can then select their own image to replace the existing. If they right click the image then it is 'deleted' from the document (but the source image is left unchanged wherever it is stored).
4) If the text runs to additional pages then they also have the three images down the side.

In theory this should be workable but I have hit the issues that you righlty highlight. The need for code for each object is a right royal pain but I think I can work around it if there is some way to figure out how to detect new pages.

You ask how EXACTLY I inserted the image controls:

1) Unprotect the document
2) Click the image button on the controls toolbar.
3) Locate the image on the page & size it accordingly
4) Write the code for the new image
5) Protect the document

As I said, there are loads of functionality and useability issues with this template at the moment but I want to sort out the basic framework first.

Thanks for you rongoing help on this.

fumei
12-30-2007, 02:33 AM
You ask how EXACTLY I inserted the image controls:

1) Unprotect the document
2) Click the image button on the controls toolbar.
3) Locate the image on the page & size it accordingly
4) Write the code for the new image
5) Protect the document

Sorry...not buying that. I just did those steps - although the document was not protected.

The ActiveX image controls inserted are NOT, repeat NOT, the same as the ones in your attached document.

Why? Because they are InlineShapes - which you said they were...but...sorry....the ones in your attached are NOT InlineShapes. They are Shapes. And you, yourself, use Shapes in your own code....as I have pointed out.

So....no, that is is not EXACTLY how you did them. I simply do not believe it. Those steps 1 - 5 do insert image controls, true. But again, they insert InlineShapes.

And your document does not have InlineShapes. They are Shapes. You must be doing something else extra. But what?

Try again to explain, if you would. The reason I ask (and i understand that this is not strictly speaking in context to the thread) is that I can not seem to duplicate these. So I am very curious as to how you did them.

"1) Template with limited fonts and styles with three images down the side"

OK, but again, what is the buisness case for these? Why?

"If they right click the image then it is 'deleted' from the document " Yes, the source document is untouched, but the current image control is drastically altered. This does not seem right to me.

You CAN detect/calculate if there are new pages, but you can NOT do so automatically. As stated, you can add you image controls to new pages after the fact...BUT, coding them would be a right royal pain...and unless you have a really really really good reason for trying it, it would take (IMO) much much more work than it is worth. As stated any new ActiveX controls would have to have code written for them explicitly. It is possible to write code to a VBA project, using code, but it is a pain.

I am damn curious about your Shapes though. Your "exact" steps are wrong. Those steps will NOT produce the controls as you have them.

Humpty
12-31-2007, 12:23 PM
Good to hear from you again Gerry.

You're right, I was doing the steps from memory and it is some time since I put them in.

Leaving asside the protection of the document, after inserting the controls I r-clicked, chose 'Format Control', selected the 'Layout' tab and set the wrapping style to 'Infront of text' (thus allowing the controls to be positioned as desired on the page).

I also changed the border style and SpecialEffect in the properties of the controls.

In terms of the business case, we want to have a template that has a standard layout (three images down the side) but we want the end user to be able to select the actual images for their particular document. Does this make more sense??

From what you are saying (and given my skill level!), it sounds like this is not actually going to be feasible to achieve but any suggestions would be appreciated.

Thanks again.

fumei
01-02-2008, 10:28 AM
"the 'Layout' tab and set the wrapping style to 'Infront of text' (thus allowing the controls to be positioned as desired on the page)."

My emphasis.

Why does doing this "allow" the controls to be positioned???? Because doing this converts them from....InlineShapes to Shapes.

"In terms of the business case, we want to have a template that has a standard layout (three images down the side) but we want the end user to be able to select the actual images for their particular document. Does this make more sense??"

Yes, it does make more sense...sort of. However, that is NOT a business case. It is a wish-list - "we want". A business case would clearly state why it is important, or required, to have those image controls, and why it is required the user have control over what images are in them. A business case would clearly state the purpose, and a purpose is not determined by what is possible, but by what is needed.

A business case would tell me, exactly, why those image controls are needed. I understand what you want to do, but I still have no idea why.

The answer is, as it stands, if you "need" the functionality of ActiveX controls - rather than something else - then no it is not realistic/possible. The problem lies with the ActiveX controls themselves. To perform the functions you want requires code. This code must be written for each object.

Yes, you could add controls to any new pages.
No, you can not do this automatically when a new page is created.
No, the code functionality of any new controls could not be created automatically.
Yes, the code functionality of any new controls could be created (written) as part of the control creation process itself.

Yes....it would be a pain in the butt. I may post a thread sometime later on, as I have become a little curious as to how hard it actually would be. So I am, in fact, attempting to do this. First effort? It is not trivial.

I can not suggest what a "something else" may be...as I still do not understand what the business case is.

Humpty
01-02-2008, 11:20 AM
Thanks Gerry, your analysis and questions on this are most helpful in getting me thinking around the issues.

I will try and outline the business case rather than just the wish list:

End users are putting together tenders that go out to a number of different types of clients; the images that are inserted in the document need to reflect the nature of the tender and will change with the type of client. All documentation that is sent out of the company has a standard layout and we need to enforce this layout in these forms as well. We are keen to limit the layout of the document (in terms of the size and position of images) as users tend to end up with messsy and badly formatted documents when left to their own devices. Clicking on the image control and then selecting a new image for the control seemed to be a good way of implementing this.
Looks like I have drawn a blank on this though. Shame really as it looked so promising in the early stages. :(

fumei
01-02-2008, 01:34 PM
" as users tend to end up with messsy and badly formatted documents when left to their own devices"

Crack me up. True, very true. I am in total agreement with attempting to have standardized documentation. No issue with that whatsoever. I have been trying for 25 years....

"Clicking on the image control and then selecting a new image for the control seemed to be a good way of implementing this."

No. Flat out...no. Well...yes...in terms of attempting to keep a standardized format and structure. Which is good.

So yes, doing it this way does indeed accomplish that goal.

However, and I keep asking this...WHY do you require user control of the images? That is the business case I refer to.

Look, maybe I can go about this another way.

You state that there are image differences required. Fair enough, that is reasonable as a requirement. But read what you stated.

"End users are putting together tenders that go out to a number of different types of clients; the images that are inserted in the document need to reflect the nature of the tender and will change with the type of client"

My emphasis. So. Think about this. Read it again. HERE is the business case:

1. A document with images inserted.
2. The images inserted vary according to the type of document.

THAT is the business case.

Keep on thinking about this. The images vary according to the type of tender and/or the client.

OK. Reasonable.

However......WHY, what is the business case, for the user to do this in the document??????

WHY does the document itself require active functionality in the document to change the images?

That is what I am trying to ask for in repeaterdly asking what is the business case.

Let me propose an alternative.

A template (.dot) file. When a new document is cloned (via File > New), a userform starts up.

On the userform the user selects the type of document - and what that actually means is up to you. It does not matter. This is a question of logic, as most things are.

The user selects Yadda, however that is defined. The type of tender (details of which are outside my expertise), in combination with the client. It does not matter.

Once the user selects the type of document, the template makes THAT document type. Including the appropiate images.

So, say...and I am making this up.

Type: Blah1 Client: Yogi Bear
- requires images bcvgws4, asxzgt67, qyuiia9

Type: Blah1 Client: Winnie the Pooh
- requires images bcvgws4, asxzgt67, Differentbear_11

Type: Blah1 Client: Golda Meir
- requires images lpp00as, kkghtad_1, gatt6112

Type: Blah46 Client: Santa Claus
- requires images jorq_ble, foofahla_hmmm, Look_at_6

Whatever.

Are you following this? What I am saying is that the business case is the creation of documents with variable images. This includes the users being able to make the decision as to which one type of document they need.

This is a legitimate business case. What I am saying is that - so far - I see NO business case for having active user functionality of the image controls in the document. I.e using ActiveX controls.

If all the logic required - and it IS just logic as far as I can see - is in the template then:

The users selects the type/client (again, however you define those requirements), and presses OK.

That document is created from the template, THOSE images are inserted.

The user clones a new document from the template, and selects a different type/client....and THAT document is created, and THOSE images are inserted.

I have no argument with saying there is a business case for having different documents, with different images. Happens all the time.

But I still fail to see the business case for the users changing the images on the fly. There may be one, but as it stands from what you describe, no there is not.

Tell me why they would change the images? If your answer is: to make a new document for a different tender type/client...then you have the document creation process out of whack.

Humpty
01-02-2008, 02:56 PM
Ok, I see were you are coming from.

Your logic does work, except for the number of permutations. Multiple clients, many different tenders and thousands of images. The user is putting together a tender, and on page two the text is discussing a particualr building that was altered durig a previous piece of work. User wants an image of said building alongside the text so user clicks the image control and inserts the desired image. This cannot be reasonably solved by logic applied to a form that builds the document.

I find your way of dealing with this issue fascinating and it is really getting me to think around the problems in great detail. Perhaps the best way to proceed here is to build the template with a custom toolbar that has a button that prompts the user (when clicked) for the image location (1, 2 or 3), asks which image is required and then inserts said image on the current page in position 1, 2 or 3. Could this be the answer????!!!! It might just be that you have lead me to a far more workable solution to this problem.

Now all I have to do is write some code to go behind the button.......

I'll keep you posted :thumb

fumei
01-03-2008, 10:06 AM
"on page two the text is discussing a particualr building that was altered durig a previous piece of work. User wants an image of said building alongside the text so user clicks the image control and inserts the desired image. This cannot be reasonably solved by logic applied to a form that builds the document."

My emphasis.

NOW we are getting somewhere. Quite correct. No, that would be difficult, if not impossible, to do with logic.

And therefore, user input into the image controls in the document IS a legitimate business case.

Although......

nah...maybe.....

hmmmmmmm.....

Would the user know at document creation what images they are going to need?

Anyway, this can get all complicated.

I urge you to really really think about what you need here. Write it out.
Yes, there is a business case for user decision/insertion of images. Or so it seems.

OK. But do you need these as ActiveX image controls?: Maybe. Maybe not.

You could put a button on a toolbar (or perhaps a keyboard shortcut) that would run part of your code.

Display the InsertPicture dialog, get the data, then...instead of inserting it into a control, simply places the image off to the side. A little tricky the way you have the style of your main text set up.

Perhaps have your document as an invisible two column table. Your text in the big big left column. When the user needs an image, they click your InsertImage button on the toolbar.

InsertPicture displays, yadda yadda you get the folder and file, and insert it into the cell of the right column.

Just thinking off the top of my head.

That would get rid of your new page issue. The user would simply insert an image into the right side of the document whenever they needed one.