A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

finding ways to do a task with macros



 
 
Thread Tools Display Modes
  #1  
Old July 30th, 2008, 11:43 AM posted to microsoft.public.word.newusers
domm
external usenet poster
 
Posts: 4
Default finding ways to do a task with macros

i have a file with questions only and another file with answers only.I want
to write a macro such that for every corresponding question there is a
corresponding answer going right below it.Is it possible using macros?or if
VB script is involved can anyone tell me how this can be done ?.I'd like to
do this task in the questions document. I also want to know if this can be
done in a new document.I am using word 2003.please help me.
--
domm means business whenever he talks
you may thank god your father was born before you
Kingsley amis-"Outside every fat man is an even fatter man trying to close
in":''One Fat Englishman''

  #2  
Old July 30th, 2008, 12:00 PM posted to microsoft.public.word.newusers
Graham Mayor
external usenet poster
 
Posts: 18,297
Default finding ways to do a task with macros

It should be possible to do this with a macro, but in order to do so, how
are the questions and answers identified in each of the documents? In other
Words, how would the macro know how much of the answer document to select
and how would it know where to insert it in the question document. Are the
questions and answers numbered? Are they one of more sentences or
paragraphs? Tell us more about your documents!
--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



domm wrote:
i have a file with questions only and another file with answers
only.I want to write a macro such that for every corresponding
question there is a corresponding answer going right below it.Is it
possible using macros?or if VB script is involved can anyone tell me
how this can be done ?.I'd like to do this task in the questions
document. I also want to know if this can be done in a new document.I
am using word 2003.please help me.



  #3  
Old August 1st, 2008, 01:30 PM posted to microsoft.public.word.newusers
domm
external usenet poster
 
Posts: 4
Default finding ways to do a task with macros

i have all the questions and answers in the paragraphs with 4 or 5 lines each
answer and only one line questions.
--
domm means business whenever he talks
you may thank god your father was born before you
Kingsley amis-"Outside every fat man is an even fatter man trying to close
in":''''One Fat Englishman''''



"Graham Mayor" wrote:

It should be possible to do this with a macro, but in order to do so, how
are the questions and answers identified in each of the documents? In other
Words, how would the macro know how much of the answer document to select
and how would it know where to insert it in the question document. Are the
questions and answers numbered? Are they one of more sentences or
paragraphs? Tell us more about your documents!
--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




  #4  
Old August 1st, 2008, 02:06 PM posted to microsoft.public.word.newusers
Graham Mayor
external usenet poster
 
Posts: 18,297
Default finding ways to do a task with macros

You didn't really answer the questions, however assuming the questions and
answers each comprise one paragraph, the following macro will write the
questions and answers (i.e. the paragraphs from each document)alternately to
a new document. If the answers comprise random numbers of paragraphs you
will see why I asked the question when you run the macros

Put your own question and answer document paths in the strings
sQname =
and
aAname =
lines


Dim sQname As String
Dim sAname As String
Dim Qdoc As Document
Dim Adoc As Document
Dim Target As Document
Dim i As Long

sQname = "d:\My Documents\Test\Versions\Even\Questions.doc"
sAname = "d:\My Documents\Test\Versions\Even\Answers.doc"
Application.ScreenUpdating = False
Set Qdoc = Documents.Open(sQname)
Set Adoc = Documents.Open(sAname)
Set Target = Documents.Add
Qdoc.Activate
For i = 1 To Qdoc.Paragraphs.Count
Qdoc.Paragraphs(i).Range.Copy
Target.Activate
Selection.Paste
Adoc.Activate
Adoc.Paragraphs(i).Range.Copy
Target.Activate
Selection.EndKey
Selection.Paste
Qdoc.Activate
Next i
Qdoc.Close savechanges:=wdDoNotSaveChanges
Adoc.Close savechanges:=wdDoNotSaveChanges
Target.Activate
Application.ScreenUpdating = True

http://www.gmayor.com/installing_macro.htm


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



domm wrote:
i have all the questions and answers in the paragraphs with 4 or 5
lines each answer and only one line questions.

It should be possible to do this with a macro, but in order to do
so, how are the questions and answers identified in each of the
documents? In other Words, how would the macro know how much of the
answer document to select and how would it know where to insert it
in the question document. Are the questions and answers numbered?
Are they one of more sentences or paragraphs? Tell us more about
your documents! --

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:09 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.