Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Problem on Excel to Word VBA (UK/Excel/97)

    Currently running an excel workbook containing all data required to make up word documents.
    So far, the code opens word, creates new doc based on template location specified in a cell and then proceeds to transfer selected datatables and coded text into the word document at selected locations.
    Just got a problem at the moment with the following code:

    With WordApp
    .Application.Visible = True
    With .Selection
    '.InsertBreak Type:=wdPageBreak -problem code will not insert a page break
    .typeParagraph
    .Font.Size = 12
    .Font.Bold = True
    .Font.Italic = True
    '.Font.ColorIndex = wdBlue - problem code will not change text to blue
    .ParagraphFormat.Alignment = 0

    The problem lines I have commented out for now. In essence, the code is in a "do until loop" so that at the start of each loop I want to insert a page break in the word document at the last position, before continuing with the copypasting. Also requested is to type the first bits of text in Blue color (not my choice).

    I have tried using HPageBreak to insert the page break but to no avail.
    I have also tried vbBlue for the text color but again no success.

    Thanks in advance.

    Alan

  2. #2
    Star Lounger
    Join Date
    Sep 2001
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem on Excel to Word VBA (UK/Excel/97)

    Hi Alan

    I had a similar problem once the other way around from Word to Excel. I had to use the fully qualified path for each command instead of a with/end with construction and then it run smoothly.

    hedgehog

  3. #3
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Problem on Excel to Word VBA (UK/Excel/97)

    Hedgehog,
    Thanks for the tip. For now it doesn't seem to want to know but I think I may have a 'bodge-it' solution - create a couple of lines macro in word to insert the page break, or change the font to blue, then call the macro by name from within the Excel code. So far it gets around the problem, but I'd really appreciate any help on not having to put a macro in the word template.
    Thanks again.
    Alan

Posting Permissions

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