Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

macro conversion from MS  Word 2000  to MS Word 2010

Posted on 2011-02-17
6
Medium Priority
?
631 Views
Last Modified: 2012-05-11
Any ideas as to why the following script will not work in MS Word 2010 This does work in MS Word 2000. It errors on line 3 with indicating a problem with bookmark.  This is a new PC Windows 7 Office 2010 that replaced  Windows 2000 Office 2000. I moved all word docs and template files to the same location on the new PC.

Sub GoFormal()
    Selection.GoTo What:=wdGoToBookmark, Name:="Signature"
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.InlineShapes.AddPicture FileName:= _
        "C:\Document\Templates\Formal.bmp", LinkToFile:=False, SaveWithDocument _
        :=True
End Sub
0
Comment
Question by:jlspencer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 34923948
What is the error message?

Incidentally the Selection.Find object doesn't seem to do anything.

This code should do what yours seems to be trying to achieve.
Sub GoFormal()
    With ActiveDocument
     .InlineShapes.AddPicture FileName:= _
            "C:\Document\Templates\Formal.bmp", LinkToFile:=False, SaveWithDocument _
            :=True, Range:=.Bookmarks("Signature").Range
    End With
End Sub

Open in new window

0
 

Author Comment

by:jlspencer
ID: 34926851
This is the result of running the above code


Runtime error 5941

The requested member of the collection does not exist.
0
 

Assisted Solution

by:jlspencer
jlspencer earned 0 total points
ID: 34927866
I removed the everything after :

SaveWithDocument _:=True  


Basically the Range information. Now it works fine
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 

Author Comment

by:jlspencer
ID: 34927904
Worked like a charm
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 34929078
The code required the bookmark to know where in the document to to place the picture. If it is going where you need it anyway, then the missing bookmark was unnecessary.
0
 

Author Closing Comment

by:jlspencer
ID: 34959165
I had to modify the script to get it to work correctly
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

648 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question