Consulting

Results 1 to 15 of 15

Thread: Solved: Format image in word document

  1. #1
    VBAX Regular RayClithero's Avatar
    Joined
    Nov 2005
    Location
    Sherbrooke, QC Canada
    Posts
    7
    Location

    Question Solved: Format image in word document

    Hello all,

    I have searched through this and a number of other forums and cannot find a procedure for fomatting an image in a word document.

    I am relatively new at VBA so bear with me. The project is basically label creation. I need to create templates in word that I can populate with info from Access. I will worry about that link later. Right now I just want to try to replace the logo (.pcx) file in the template with another one while retaining the size. This is essential as I have roughly 12000 PCX files and I reeeaaallly don't want to go through and resize them all manually :P


    Any help would be greatly appreciated.
    Ray
    VBA Newbie

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Hi Ray. Welcome to VBAX.

    This is not really a viable option in Word. Word is NOT (even if Microsoft pretends that it can be) a graphics package.

    I have a question though. You have 12,000 different logo files????? All you are going to use them all? This is hard to believe. Could you describe the actual situation you are in? More details please.

  3. #3
    VBAX Regular RayClithero's Avatar
    Joined
    Nov 2005
    Location
    Sherbrooke, QC Canada
    Posts
    7
    Location

    Unhappy 12000 pcx files

    Indeed we do have 12000+ pcx logos. We are a "Large" coffee roastery. We package our coffee for hundreds of private labels. This is just the box labels we have 35,000 different labels that go onto the individual bags. But that is another story...

    The thing is we are moving to an Oracle database with Access as a front end. But the current label software is a nightmare. We want to standardize things, but we don't want label creation to be a full time job (the guy doing it now has better things to do).

    Oh well, I guess we will have to find another label program that we can push data to with VBA or .Net

    ... means I will have to learn .Net

    Thanks Anyway
    VBA Newbie

  4. #4
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    I am not grasping this. This does not seem to me (at least in your original requrest) to be a label issue at all. It is a graphics issue.

    What are you doing? You are replacing the pcx...with WHAT? JPG? You can certainly push data to Word and make labels.

    You asked about formatting an image in Word. But it sounds like you are not "formatting", you are replacing. That is not formatting. Are the templates existing already? Are they real templates, or are they documents? If they are templates (real ones), then do you need to run through abunch of them replacing the pcx with ...whatever? You can do that with VBA, and could, depending on exactly what you have happening, do some resizing using the pcx as InlineShapes.

    Hard to say until you state exactly what you have happening. But again, this does not seem to be a label issue.

  5. #5
    VBAX Regular RayClithero's Avatar
    Joined
    Nov 2005
    Location
    Sherbrooke, QC Canada
    Posts
    7
    Location
    Very simple. We want to start over from scratch. We need one label for every product. The products are user specific in most cases ergo the logos. The users will enter the Logo(s) and the text on a form in Access. We want to push that info into one of several templates, that will then be saved as a new file in a directory accessible to production. When they need to package for client "x" they will click on the product on the production order and the label that we generated in the above will appear.

    However none of this will happen via Word unless I find some way of automatically replacing the logo in our template, without changing the size, with the one chosen by the user.

    So as I said If this is not feasible, we will have to find some way of pushing to a label program instead.

    Ray
    VBA Newbie

  6. #6
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    I give up. Asked twice for details re: replace with what? No answer. Asked for details on process vis-a-vis- existing templates. No answer.

    If you are starting from scratch...then "replacing" is not really the right word, is it? Replacing things means you are starting FROM something, not scratch. I have been trying to find out what that something is really like. I had some ideas.

    I could think of ways of generating labels with new images, but...shrug. Could use ActiveX image controls. The reason I asked for details is simple...why do you have to REPLACE the image? I don't know what these "templates" are like...and you are not saying...so...well.

    Good luck.

  7. #7
    VBAX Regular RayClithero's Avatar
    Joined
    Nov 2005
    Location
    Sherbrooke, QC Canada
    Posts
    7
    Location

    I am not giving up... Yet.

    Quote Originally Posted by fumei
    I give up. Asked twice for details re: replace with what? No answer. Asked for details on process vis-a-vis- existing templates. No answer.
    I am not giving up... Yet. I gave you twice what I thought were the details you were looking for.
    Forgive me if it is unclear.. Let me spell it out again as clearly as I can.

    No Template exists yet.
    Correct me if I am wrong... (probably am) but I understand a template as being a word document with some data fields in it. In this case a picture, plus a few lines of text. I want to take that "Template" and replace the picture and the text with user given data, then save that as a new doc in a directory where it can be printed later as needed.

    Quote Originally Posted by fumei
    If you are starting from scratch...then "replacing" is not really the right word, is it? Replacing things means you are starting FROM something, not scratch.
    From what I just stated... We are starting from scratch... in that we will be replacing over the course of time all the existing labels. But I am trying to "Replace" an image that I have saved in my "template". But perhaps replace is not exactly the right word. I am placing a new image file into the document, but I want it to appear at the same place and the same size no matter which image I paste.

    So am I approaching this wrong? Is there actually a format called "Template" that I can place data and image fields as necessary and then just call it up and populate it with my data? If there is I would appreciate a hint as I cannot find how to create it in this version of Word. (French Office XP)

    Hopefully yours
    Ray
    VBA Newbie

  8. #8
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    I asked there was an existing template. I did assume (my mistake) that you knew what a template was.

    A Word template is a special document type, with a .DOT extension. You asked:
    Is there actually a format called "Template" that I can place data and image fields as necessary and then just call it up and populate it with my data?
    That is precisely what a template does. It is a document, what was once known as boilerplate. You use them to place locations for data (or images). The template is called and it produces a clone of itself. The original is NOT altered, the clone is. The locations are filled in with stuff - user input, or in your case, data and images. You can feed the cloning from a database if you like, something like:

    For each record (containing data and image) clone a new document and put the elements of the record into the cloned document.

    However, this is also - really - a mailmerge, which also uses a database.

    I strongly suggest you attempt a mailmerge on a smaller scale, as what you want to do is rather industrial. You will need to learn some advanced Word techniques here.

    1. is the image size standard? That is, are ALL of them going to be the same size? If so, start to learn how to use ActiveX controls. The sizing is a lot easier to maipulate than normal graphic image holders (these are either InlineShapes, or Shapes).

    2. Start to play with the macro recorder.

    I still do not quite get it. Again, replace implies that there are existing documents with old images in them. Yes....or no?

    Again..asked a couple of times...WHAT are you replacing them with? You are replacing the PCX with what??? I am not going to ask again. This is not a trivial thing you are asking about. My questions are relevant. You may think you are giving details, but if you do not actually answer the questions, sorry...how can you think you are giving details?

  9. #9
    VBAX Regular RayClithero's Avatar
    Joined
    Nov 2005
    Location
    Sherbrooke, QC Canada
    Posts
    7
    Location
    Let us try to speak the same language here.

    First off. Thank you for the precision on what a "Template" DOT file is and can do.

    I said we need to generate labels from a template, so when I said "replace" I meant I wanted to plug an image onto the template in the same place and same size each time.

    Obviously then if I use a DOT file I am not replacing anything. Where the confusion lay was in the definition of "template". I had in mind creating standard DOC file. Let us call it "label1.doc" I was trying to find a way of opening that file and replacing the information in it (pictures... text.. whatever) with other information (pictures.. text... whatever) supplied by the user. All the pictures already exist but in different sizes.
    My problem with the images, as I implied in my first post, is that they are NOT uniform in size or shape and I do not have the time or energy to go through the entire directory and resize them all.

    From what I gather, this is the wrong approach.
    I need to create a DOT file then.

    I played around with creating merge fields... For text.. No problem. But I do not know how an image field is created. Everytime I tried to insert an image into a document it is too large. It needs to be manually resized. I tried getting code for this by programming the resize via macro, but for some reason I cannot choose an image while recording a macro. I am trying to make this as foolproof as possible. No user intervention required other than stating which template to use and the data (picture...text) to be merged.

    How do I create an image field in my template? One that will retain the same size and position regardless of the size of the image that is merged with it.

    I have looked at the merge function in word, and I conclude that while it could work, what we want to do is not the original intention of the merge function. We do not have a database of images and text that we can just push a button and create all the new labels from. What we have is a folder full of images used by the current label software that we will re-use in the creation of new labels. The text to be linked will be supplied over a period of time as we need the new labels. This would be done one at a time.. not 50, 100 or more.

    Perhaps then I have wasted my time and yours.

    I will look further into finding a way of accessing our current label software via Access or VB. However if you have any really good ideas I would much appreciate them.

    Thank you for your time.

    Ray
    VBA Newbie

  10. #10
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    From personal experience in writing documentation, I can tell you that Word will have a major seizure if you attempt to have 12000 images in one document.

  11. #11
    VBAX Regular RayClithero's Avatar
    Joined
    Nov 2005
    Location
    Sherbrooke, QC Canada
    Posts
    7
    Location
    Quote Originally Posted by geekgirlau
    From personal experience in writing documentation, I can tell you that Word will have a major seizure if you attempt to have 12000 images in one document.
    Did I say anything about putting all 12,000 in one doc?!!!

    I want to create 10,000 docs (Labels) from templates... each with maximum of 2 or three images.
    VBA Newbie

  12. #12
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Whew, that is a relief. Actually, I for one never imagined that you were going to use 12,000 images in one document. It is for a label after all...

    Going back to the original post. There is no way to do this kind of resizing efficiently in Word. Word is simply not a graphics application. The object model does not allow easy access to image resizing - as you have discovered. You can not use the macro recorder to get sizing functions.

    Bottom line. Determine the size needed and get a graphic application that can handle large scale batch processing. Let that application resize the images. It would be worht the cost. Trying to do this with Word is not worth the effort to come up with good code. Even writing a VB app to do it is not worth it. There are commercial graphics applications that will do this.

    However, the template route is where you want to go for doing the inserts.

  13. #13
    VBAX Regular RayClithero's Avatar
    Joined
    Nov 2005
    Location
    Sherbrooke, QC Canada
    Posts
    7
    Location
    Quote Originally Posted by fumei
    Going back to the original post. There is no way to do this kind of resizing efficiently in Word. Word is simply not a graphics application.
    Thank you for your input Gerry.

    In the end I just met with a friend who does programming in VB, VBA, C++, .Net etc... We found a way to link directly to our existing label software.

    Problem solved... Without Word

    Now lets see if I can figure out how to mark this thread as complete
    Cheers
    Ray
    VBA Newbie

  14. #14
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    Glad you sorted this out Ray. Gerry is absolutely right - Word is awful with graphic images. Just out of interest I had a quick look at the InlineShapes object in VBA, and from what I can gather you can't change the name of the image in use, you can only set this when adding a new picture. Given how tricky it is to get an image in Word to act even remotely as you want it to, I think this one definitely goes into the too hard basket.

  15. #15
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Ray, this is what I was saying at the beginning. Word is NOT for graphics processing.

    However, I do suggest that you look at another thread -
    "Macro to insert image and caption"...or something like that.

    I suggest using ActiveX label controls. This MAY help for another use, as label control resize the loaded image to the size of the control.

    geekgirlau - I do not use InlineShapes for graphic sin Word anymore. Or Shapes for that matter. ActiveX controls give so much more control, and they have events!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •