Solved

macro conversion from MS  Word 2000  to MS Word 2010

Posted on 2011-02-17
6
624 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 500 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

736 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