- Local time
- Today, 02:18
- Joined
- Feb 28, 2001
- Messages
- 29,452
I have searched this site and many others. Web searches galore, but nothing seems to work quite right for me.
I am making a document linearly. I.e. providing headers and text and bookmarks and other material in the sequence that I would expect them to be read. But it ain't working. I think I must have deeply offended the Word gods. Word from a GUI with mouse and keyboard can be a real pain, but from VBA is beginning to make me believe that we should shoot the entire Word developer group and start over. It is INSANELY difficult.
Trying to use ranges, I will try range.InsertAfter "text" but it goes in the wrong paragraph. Using range.InsertBefore puts things in the wrong order. When I try instead to use Selection.TypeText, what happens is that when I go back to apply formatting, it goes to the wrong place. Using Selection.TypeParagraph also puts things in the wrong place. I have tried various tricks to collapse the Selection object to become a simple insertion point but it won't stay that way. If I try to insert a paragraph marker, that doesn't seem to work. If I try to insert a line break, they go to the wrong place, like my insertion point isn't where I think it should be. It seems to be jumping all over the place and I can't make it behave.
I can generate ALMOST what I want by making an Access report, but that's not good enough. I want the features that include the ability to add an index entry and then pop out a names index. Not to mention that it has now become an intellectual challenge.
What is the correct way to linearly insert text and paragraph breaks in Word from VBA, more or less like I was typing it in the order it should be presented?
I am making a document linearly. I.e. providing headers and text and bookmarks and other material in the sequence that I would expect them to be read. But it ain't working. I think I must have deeply offended the Word gods. Word from a GUI with mouse and keyboard can be a real pain, but from VBA is beginning to make me believe that we should shoot the entire Word developer group and start over. It is INSANELY difficult.
Trying to use ranges, I will try range.InsertAfter "text" but it goes in the wrong paragraph. Using range.InsertBefore puts things in the wrong order. When I try instead to use Selection.TypeText, what happens is that when I go back to apply formatting, it goes to the wrong place. Using Selection.TypeParagraph also puts things in the wrong place. I have tried various tricks to collapse the Selection object to become a simple insertion point but it won't stay that way. If I try to insert a paragraph marker, that doesn't seem to work. If I try to insert a line break, they go to the wrong place, like my insertion point isn't where I think it should be. It seems to be jumping all over the place and I can't make it behave.
I can generate ALMOST what I want by making an Access report, but that's not good enough. I want the features that include the ability to add an index entry and then pop out a names index. Not to mention that it has now become an intellectual challenge.
What is the correct way to linearly insert text and paragraph breaks in Word from VBA, more or less like I was typing it in the order it should be presented?