Results 1 to 3 of 3

Thread: Word labels

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Word labels

    ok this is more of an Office Word API question. I hope to get some insights....

    basically, I am able to copy/replace text in a word document into a new one - thats cool!

    what I want to do now is the same thing BUT, if the document has labels on it - we want to copy the labels up to whatever the max we can onto a single page before having it insert a new page and repeat that process.

    So for example, we may want 6 rows and 2 columns of labels. In each label, we will be doing the find/replace search, which shouldnt be a problem but what the problem is right now, is to have it copy a label from a master template into a new document (kind of there/know how) but how can we paste it into the new document for the number of times on 1 page if we predefine this "max value"?

    so I may want say, 3 rows and 2 columns of labels. or maybe 4 rows of 1 column of labels.....

    ive also just noticed that it doesnt seem to read the document text if it has graphics! (example load a template and then type in whatever you want in the template in one of the text fields)

    the code ....

    Code:
    aDoc.ActiveWindow.Selection.WholeStory();
    			aDoc.ActiveWindow.Selection.Copy();
    			//anotherADoc.Content.Paste();
    
    			foreach (UserEntity currentGuest in collectionOfGuests)
    			{
    				anotherWordApp.Selection.Paste();
    				anotherADoc.ActiveWindow.Selection.Select();
    				anotherWordApp.Selection.Find.ClearFormatting();

    how is this possible?
    Last edited by Techno; Apr 11th, 2007 at 08:33 AM.

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: Word labels

    ok well ive kind of got it done. I am able to create a table - yay!!! however I need to create several tables, thing is it doesnt appear to be doing it but creating one big table. How can I tell it to set the range to be outside the table so it can create a new one?

    Code:
    			Microsoft.Office.Interop.Word.Table table;
    			Microsoft.Office.Interop.Word.Range tableRange = anotherWordApp.Selection.Range;
    			table = anotherWordApp.Selection.Tables.Add(tableRange, this.numberOfRowsToCreate, this.numberOfColumnsToCreate, ref missing, ref missing);
    		
    //for loop here
    
    if (currentColumn < this.numberOfColumnsToCreate)
    				{
    					currentColumn++;
    				}
    				if (currentColumn == this.numberOfColumnsToCreate)
    				{
    					currentRow++; //move on to the next row
    					currentColumn = 1;
    				}
    
    				anotherWordApp.Selection.Tables[anotherADoc.Tables.Count].Rows[currentRow].Cells[currentColumn].Select();
    				anotherWordApp.Selection.Paste();
    				//anotherADoc.Select();
    				aDoc.Content.Select();
    				aDoc.Content.Copy();
    anotherWordApp.Selection.InsertNewPage();
    					table = anotherWordApp.Selection.Tables.Add(anotherADoc.Tables[anotherADoc.Tables.Count].Range, this.numberOfRowsToCreate, this.numberOfColumnsToCreate, ref missing, ref missing);
    					
    
    //end for

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: Word labels

    ok almost done.
    how can I set the Range or somehow, move to the end of the document or outside the existing table?

    I see that the rows are being created correctly initially (3 rows) but then when its time to create a new table, I see that it creates 2 rows instead....

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

Posting Permissions

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



Click Here to Expand Forum to Full Width