How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask Michael Hannigan Your Own Question
Michael Hannigan
Michael Hannigan, Consultant
Category: Programming
Satisfied Customers: 11866
Experience:  25+ Years Experience in Field. Multi Platform Developer.
Type Your Programming Question Here...
Michael Hannigan is online now
A new question is answered every 9 seconds

I need to make a macro to make my work easier...I

Customer Question

Hi, I need to make a macro for Word to make my work easier...I tryied a bit of work on my own but it seems it´s not working properly
Submitted: 2 years ago.
Category: Programming
Customer: replied 2 years ago.
I send two files as little example. Dokument1 technical norms are out-of-date, Dokument2 technical norms are up-to-date. I want those out-of-date norms to be replaced with up-to-date norms. :) I highlighted in text in both documents first and last technical norm - just to give you example of what I mean by technical norm. Thanks in advance!
Expert:  Michael Hannigan replied 2 years ago.
Hello. My name is***** can help you with your question. I can see that the texts are different in small ways. Is there a set of rules that you follow to do these replacements? At first glance it looks like something you can but I'm assuming there is more complexity to it than that.
Customer: replied 2 years ago.
So at the moment I am working with this macro (down), but there is a limit of it - I have to select manualy the norm I want to update. Is there a way to make a skript or perhaps a little VBA application, that would simply automatize this proces, so that I could only pick the Word file I want to update and push the button? There is the script I am using now:Sub Macro1()
'Macro by G Mayor 23 May 2015
'Modified 26 May 2015
Dim oDoc As Document
Dim oTable As Table
Dim oSource As Document
Dim oRng As Range
Dim oFind As Range
Dim strReference As String
Dim bFound As Boolean
Set oDoc = ActiveDocument
Set oRng = Selection.Range
oRng.Text = Replace(oRng.Text, Chr(160), Chr(32))
strReference = oRng.Text
If Len(oRng) < 6 Then
MsgBox "Select the reference first!", vbCritical
GoTo lbl_Exit
End If
Set oSource = Documents.Open(Filename:="C:\Path\Dokument2.docx", _
AddToRecentFiles:=False, Visible:=False)
For Each oTable In oSource.Tables
Set oFind = oTable.Range
oFind.Text = Replace(oFind.Text, Chr(160), Chr(32))
With oFind.Find
Do While .Execute(FindText:=strReference)
bFound = True
oFind.MoveEndUntil "("
oFind.End = oFind.End - 1
oRng.Text = oFind.Text
Exit Do
End With
Next oTable
If Not bFound Then
MsgBox "The selected reference was not found in the reference table.", vbInformation
End If
oSource.Close 0
Set oDoc = Nothing
Set oSource = Nothing
Set oRng = Nothing
Set oFind = Nothing
Exit Sub
End Sub
Customer: replied 2 years ago.
I also want to send you bigger files, so that you maybe get the idea, how I work with those technical norms.
Customer: replied 2 years ago.
I have also some ideas how to select the exact string of text, using number of conditions, I try to write them down, It should help you a lot I think