Swap between Macros and document

D

Designingsally

Hi i got this document for which macros are created. When the macros are
running, then my mouse cursor rotates when i place them in the document i m
not able to work on the document. My macros have message box. Is it possible
where my doc at the back remains active not inert and make changes when as
the macros are run. Like create a minimize button as i click that that
minimize next to X button in the macro and i make changes to the doc. is that
possible??
pls help me out.
 
P

Pesach Shelnitz

Hi Sally,

I don't know a way to do exactly what you are describing, but you can have
something similar. Your macros generally include the following line (or an
equivalent line inside a With block), which makes the search start at the
beginning of the document.

Selection.HomeKey wdStory

If you remove this line, the macro will start at the cursor location. Thus,
if users would click Cancel when asked to confirm a change, they could edit
the document and call the macro again to resume the process from the point
where they stopped editing.

Instead of removing this line, you could add code around it to display a
message asking users if they want to start at the begnning of the doc or at
the current cursor location.
 
D

Designingsally

thanks for the reply. let me explain to you so that you can understand
better. Probably you can also advise if this is feasible or not.

consider a simple program and data given below. And now copy this word fine
for abt a page. Just that word alone. Now run the macro. THe macro ll run
good. While running the macro keep ur mouse inside the message box u can see
the mouse pointer. but when u keep the mouse poiner outside the message box
u can see the pointer keep on rotating. Now, under this condition i m unable
to edit the document when the macros are running. is it possible to edit the
documetn or NAVIGATE through teh document when the macros are runnin.

thanks for the reply in advance.




Sub check()
Dim orng As Range
Dim sRep As String
Dim sFindText As String
Dim sRepText As String
sFindText = "fine" 'the word to find
sRepText = "finD" 'the word to replace
With Selection
..HomeKey wdStory
With .Find
..ClearFormatting
..Replacement.ClearFormatting
..Wrap = wdFindContinue
..Format = False
..MatchCase = True
..MatchWholeWord = True
..MatchAllWordForms = False
While .Execute(findText:=sFindText)
Set orng = Selection.Range
sRep = Msgbox("Replace with finD?", vbYesNoCancel)
If sRep = vbCancel Then
Exit Sub
End If
If sRep = vbYes Then
orng.Text = sRepText
End If
Wend
sFindText = "many" 'the word to find
sRepText = "ues" 'the word to replace
With Selection
..HomeKey wdStory
With .Find
..ClearFormatting
..Replacement.ClearFormatting
..Wrap = wdFindContinue
..Format = False
..MatchCase = False
..MatchWholeWord = False
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
While .Execute(findText:=sFindText)
Set orng = Selection.Range
sRep = Msgbox("Replace with uses?", vbYesNoCancel)
If sRep = vbCancel Then
Exit Sub
End If
If sRep = vbYes Then
orng.Text = sRepText
End If
Wend
End With
End With
End With
End With
End Sub
 
P

Pesach Shelnitz

Hi Sally,

As far as I know, it is not possible to directly edit a document while a
macro is running.

Pesach
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top