Solved

Word - Visual Basic code

Posted on 2011-03-20
12
364 Views
Last Modified: 2012-05-11
I am trying to do a mail merge to print addresses into a document.  Each address block would be a record by itself, because the paper size will be 8.5 x 8.5.
Once the addresses have been merged into a document and then saved.
I would like to open this document and then run a code that will invert the whole address block, and then go to the next address block and do the same until EOF.
For instance, an address could be as in the document attached, and then please see how the inverted address would like.  
To make coding easier, I could put a delimited for the start of the address, and another one at the end of the address block, but when inverting the address, these delimiters have to be excluded.
Can someone please  suggest some solutions for this project.  I have tried twidling with the Printer drivers and also examining the printer menu on the printer, but there is nothing that could do this, because the Xerox 4500 Printer that I have is not an envelope printer.  in some envelope printers like Pitney Bowes I think have the feature of feeding the mail piece bottoms up and then printing the address inverted.  This is because the other end of the mail piece has open flaps that would jam the printer. thank u for your inputs.
Another thought I have is, from Access when it prints the address line by liine, to print it inverted.
Thus an address line like
   John Doe
would print as :
   eoD nhoJ
is this a workable solution for this inverted printing?
Sorry I forgot, I use Windows 7 and Microsoft Word 2007 and the data file will be from Access 2007.
upsidedown.docx
0
Comment
Question by:jegajothy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +2
12 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35175757
From your sample, it looks like you will be "Folding" this paper..?

If so, then consider running it through the printer twice.
Once "Flat", then Folded.

In other words set the "Printout" to be the same, then just fold/reorient the paper, ...and print it through again.

This should same you all the jerking around with trying to "Invert" the text

Just a suggestion...

Let's see what some other Experts post...

JeffCoachman
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 35176034
You could put the text and mergefields in two side-by side text boxes, with the text direction running upwards in one and downwards in the other.
0
 

Expert Comment

by:13cactus
ID: 35176130
I think the easiest would be like this:

1. Set the page orientation to landscape
2. Add a table with one row and two columns spanning the page (in height and width)
3. Set the text direction on the left cell bottom to top
4. Set the text direction on the left call top to bottom
5. Add the merge fields and layout in the left and right column

Please see attached document for an example.
example.doc
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Expert Comment

by:Norie
ID: 35176231
How about doing it side by side?

Then you could use a table with 2 cells for each address and set the rotation in one of the cells to 180.

I came up with this but I'm not sure it's anywhere near what you want.

Try it on a document with just the address which has been bookmarked as 'Address1'.
Option Explicit

Sub Macro1()
Dim tbl As Table
Dim celLH As Cell
Dim celRH As Cell

    Set tbl = ActiveDocument.Tables.Add(ActiveDocument.Bookmarks("\EndOfDoc").Range, 1, 2)
    
    Set celLH = tbl.Cell(1, 1)
    
    celLH.Range.Text = ActiveDocument.Bookmarks("Address1").Range.Text
    
    celLH.Range.Orientation = wdTextOrientationDownward
    Set celRH = tbl.Cell(1, 2)
    
    celRH.Range.Text = ActiveDocument.Bookmarks("Address1").Range.Text
    
    celRH.Range.Orientation = wdTextOrientationUpward
    
    tbl.AutoFitBehavior wdAutoFitContent
    
 End Sub

Open in new window

0
 

Author Comment

by:jegajothy
ID: 35180359
in response to imiorie, I got a runtime error.  This is what I did, I created a 3 row table of one column.
Then I inserted the address one line per row.
and then I ran your macro, and I got a runtime 5941 error, sometthing like collection does not exist at the following line when i debugged it :
    celLH.Range.Text = ActiveDocument.Bookmarks("Address1").Range.Text
Being a novice, I have no clue how to fix this error.  Hope u can help. thank u.
0
 

Author Comment

by:jegajothy
ID: 35180413
in response to 13cactus, your sample doc shows the result.  But I am lost of how u achieved it.  Do you think u could please give me a step by step instruction.  thank u.
0
 
LVL 34

Expert Comment

by:Norie
ID: 35180667
Don't create a table, just type in one address, select it and bookmark it with the name 'Address1'.

Now run the code.

It should create a table with the address shown twice side by side but aligned 'downwards' in the left cell and 'upwards' in the right cell.

Actually you should probably go with 13cactus' idea which you should be able to do without code.

I'm not exactly sure how it's been done, not downloaded the file yet, but I know there is a way to repeat merge fields.

I think that's probably one of the things you need to do, ie repeat the address
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 35181374
Have you tried the textboxes suggestion? It doesn't need any code, because you lay it out in the Main merge main form.
Here is an example
 
Textboxes.docx
0
 

Author Comment

by:jegajothy
ID: 35181894
thank u everyone, I tried imnorie's suggestion, but the result is not what I expected.  This is what I did, I typed a single address.  Then highlighted it and inserted a bookmark called Address1.  Then I ran the code, please see attached file I got.   Upside-down-result.docx
0
 
LVL 34

Accepted Solution

by:
Norie earned 500 total points
ID: 35182894
Here's a picture of what my code created using the workbook you attached.

All I did was remove the existing table as the code I posted creates a table.


WordTable.JPG
0
 

Expert Comment

by:13cactus
ID: 35182902
in response to 13cactus, your sample doc shows the result.  But I am lost of how u achieved it.  Do you think u could please give me a step by step instruction.  thank u.

Did you look at the post that contained my attachment? There is a instruction in there how I did it. Unfortunately I seem to use an older version of Office so I can not give you a step by step instruction with the proper menus and options, but I think you should be able to start with the instructions given earlier:

1. Set the page orientation to landscape
2. Add a table with one row and two columns spanning the page (in height and width)
3. Set the text direction on the left cell bottom to top
4. Set the text direction on the left call top to bottom
5. Add the merge fields and layout in the left and right column
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 35183470
Sorry that your question is now extremely confusing. However, I will add a couple of comments. If you wanted to use tables instead of text boxes, it would be best to have two tables side-by side, otherwise you would have to predict the fold very accurately.

Also, your paper format is square, so it isn't easy to see what difference the orientation (landscape or portrait) would make. However, since you are concerned with printer feeding, it might be worth-while experimenting.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question