1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Vba, word, movedown doesn't work

Discussion in 'Business Applications' started by balloon_tom, Jan 5, 2011.

Thread Status:
Not open for further replies.
  1. balloon_tom

    balloon_tom Thread Starter

    Joined:
    Jan 4, 2006
    Messages:
    107
    This is my first attempt at using macros with Word (2003). I can macro my way through Excel pretty well, but Word is a different story. It's sloppy, but plesae bear with me. (Any suggested improvements are welcome).

    This Word project is opened by Excel and variables are passed to it through the PrintTable macro. I have created a Sub Test() macro which populates all the variables and runs the project without the need for the Excel.

    The project begins by searching for 4 sentences/paragraphs, and then deleting them if they exist. Sub Delet() sets the first phrase to search for (Strt) and the last (Stp). Sub DelText() searches the document and accomplishes the deletion.

    3 of the 4 work perfectly, but the deletion starting with the word "WAIVER:" does not. It worked yesterday, but not today.
    The sub finds the Strt phrase and then moves up seaching for the first non blank line. So far, so good. It then does a MoveDown with Extend seaching for the Stp phrase. With the 3 working deletions, this MoveDown works, but with WAIVER, the move is not done.

    Can you see what I'm missing?
    Thanks,
    Tom
     

    Attached Files:

  2. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    Can you please explain exactly what you are trying to do? My first impression is that you are trying to use this Word doc as a template that will be filled with data rows from an external source? Please provide a detailed explanation of your entire process and I am sure I can provide you with a more efficient and easier way of doing this. I am very proficient with writing macros for all Office applications.

    Rollin
     
  3. balloon_tom

    balloon_tom Thread Starter

    Joined:
    Jan 4, 2006
    Messages:
    107
    Thank you for your time, Rollin.

    This is a confirmation letter/email sent to my customer after they have booked a hot air balloon ride with me via a telephone conversation. I enter their information (names, phone numbers, flight date and time, and payment info, etc) into an Excel workbook. When I am ready to send the letter/email, a macro within the Excel workbook opens this word.doc. The Excel macro also calls the Sub PrintTable() macro within the word doc and passes 17 variables, (v0 throughv16, the flight/passenger information). (Because you do not have the Excel workbook, I have added a macro named Sub Test(). Running this macro will simulate the Excel's part). These variables then populate (or are modified before population) various DocVariables or other parts of the word doc. There are 4 sentences/paragraphs which may (or may not) be included in a specific customer's letter. Therefore, the PrintTable macro first checks to see if these sentences were inadvertantly saved from the last doc use. If they are present, they are to be deleted. Then frmData opens populated with the Excel data. I use this form to 'personalize' the letter. For example, by default, the greeting, "Hi so and so", is populated with the first name in the passenger name list (v4, or in the case of the test version, "John Doe & Mary Smith). But, the first passenger may not be the one getting the letter...so I can click on Greeting and select a different greeting name. There is a a sentence "Call me a day or two before the flight. If the pasengers book this flight a week before the flight date, I will include this line. However, if they call to fly that same day, that sentence will be excluded. If the flight is a morning flight, the sentence about calling me the night before will be included, but an afternoon flight will not have it. I may or may not choose to include the waiver with this correspondence. These are all options selected within frmData. Clicking OK then populates the actual document.

    Thry running Sub Test() and I think you'll see what I mean. I do have stops and comments around the MoveDown command that sometimes works and sometimes doesn't.

    Does this help clarify a little?
    Tom
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/972818

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice