|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Looping through word and writing to excel when certain conditions are met
Apologies up front if this has been answered in a previous post, however I've been looking for a number of days now and haven't been able to solve my problem.
I have a macro which loops through all paragraphs in a word document. While it loops through, it evaluates the font style, and updates a number of variables which will be passed to excel when a condition is met (para.style = normal). I then want to take the variables and write them to a new row in excel. It then goes back to the word document and resumes looping through the paragraphs until the condition is next met. When I was first writing the code, I was using an earlier OS and version of office, and the existing code worked to completion and the excel worksheet was fully populated with the full content of the word Document. When I tried to run the code on my machine (which I use more often than not) and start handling other issues (tables), the macro worked to the point of creating the first row in excel, but when it came to writing the next (and subsequent rows), it doesn't appear to activate the worksheet. I have attached the code and the target xls sheet. I'd be appreciative if anyone can steer me in the right direction. |
#2
|
|||
|
|||
I would suggest that in your code, you start Excel and open the workbook right at the start, rather than doing that each time a Normal style paragraph is encountered.
|
#3
|
|||
|
|||
Doug,
Thank you for that suggestion. The problem with having it where it was (other than being untidy and redundant) was that I re-initialised the xlRow variable to 2 every time, so in fact I was simply rewriting everything to the same row, instead of incrementing the counter and writing to the next row. One of those mistakes when you're overtired and been looking at something too long! Cheers, Irene |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Excel Formula for Multiple Conditions & Results | nowco | Excel | 4 | 03-16-2016 11:24 AM |
Writing PDF from Mac Word | dickmill | Word | 0 | 01-13-2016 08:17 AM |
Generating Multiple Word Docs from Master Depending on Conditions | ljg713 | Word VBA | 6 | 12-09-2015 03:23 PM |
How to stop MS word writing in margin | gerretw | Word | 2 | 02-05-2013 07:01 AM |
Replacing cells in Excel-Very basic with minor conditions | mag | Excel | 1 | 10-26-2012 10:59 AM |