Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-21-2023, 12:41 PM
Ulodesk Ulodesk is offline Compile error -- incompatibility? Windows 10 Compile error -- incompatibility? Office 2021
Word 2013 Expert Cert
Compile error -- incompatibility?
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default Compile error -- incompatibility?

I am not a coder. I've into a problem with a colleague after walking him through installation of a macro over the phone.



When he runs it, he's getting a message of a compile error and "Method or data member not found." In VB, the first line, with the macro name, is highlighted with a yellow pointer, and teh line ".NumberSpacing = wdNumberSpacingDefault" is highlighted in blue.

He is using Word 2007. Could this be a compatibility error?

Here is the code:
Code:
Sub EIRPreEdit()
'
' Macro to format the entire document to Times New Roman 14 pt 6/6, single space, left-aligned
' replace straight single and double straight quotes with curly, and transpose commas and periods to inside of close quote
' remove tabs;
' replace two or more consecutive character spaces with a single one
' replace manual line returns with hard returns; and
' remove empty paragraphs
'
'
       Selection.WholeStory
    With Selection.Font
        .Name = "Times New Roman"
        .Color = wdColorAutomatic
        .Size = 14
        .Spacing = 0
        .Scaling = 100
        .Position = 0
        .Kerning = 0
        .NumberSpacing = wdNumberSpacingDefault
        .NumberForm = wdNumberFormDefault
        .StylisticSet = wdStylisticSetDefault
        .ContextualAlternates = 0

With Selection.ParagraphFormat
        .LeftIndent = InchesToPoints(0)
        .RightIndent = InchesToPoints(0)
        .SpaceBefore = 6
        .SpaceBeforeAuto = False
        .SpaceAfter = 6
        .SpaceAfterAuto = False
        .LineSpacingRule = wdLineSpaceSingle
        .Alignment = wdAlignParagraphLeft
        .Hyphenation = True
        .FirstLineIndent = InchesToPoints(0)
        .OutlineLevel = wdOutlineLevelBodyText
        .CharacterUnitLeftIndent = 0
        .CharacterUnitRightIndent = 0
        .CharacterUnitFirstLineIndent = 0
        .LineUnitBefore = 0
        .LineUnitAfter = 0
        .CollapsedByDefault = False
    End With
    
    With Selection.Find
        .Text = "^t"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.MoveLeft Unit:=wdCharacter, Count:=1
    
        .Text = "'"
        .Replacement.Text = "'"
        .Forward = True
        .Wrap = wdFindContinue
    Selection.Find.Execute Replace:=wdReplaceAll

        .Text = """"
        .Replacement.Text = """"
        .Forward = True
        .Wrap = wdFindContinue
    Selection.Find.Execute Replace:=wdReplaceAll
 
        .Text = ""","
        .Replacement.Text = ","""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchWildcards = False
    Selection.Find.Execute Replace:=wdReplaceAll

        .Text = "',"
        .Replacement.Text = ",'"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
    Selection.Find.Execute Replace:=wdReplaceAll

        .Text = """."
        .Replacement.Text = "."""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchWildcards = False
    Selection.Find.Execute Replace:=wdReplaceAll

        .Text = "'."
        .Replacement.Text = ".'"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
    Selection.Find.Execute Replace:=wdReplaceAll

        .Text = "[^l]{1,}"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchWildcards = True
    Selection.Find.Execute Replace:=wdReplaceAll


        .Text = "--"
        .Replacement.Text = "^+"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
    Selection.Find.Execute Replace:=wdReplaceAll
    
        .Format = False
        .Forward = True
        .Wrap = wdFindContinue
        .MatchWildcards = False
        .Replacement.Text = "^+"
        .Text = " ^+"
        .Execute Replace:=wdReplaceAll
        .Text = "^+ "
        .Execute Replace:=wdReplaceAll

        .Text = "[^s]{1,}"
        .Replacement.Text = " "
        .Forward = True
        .Wrap = wdFindContinue
        .MatchWildcards = True
    Selection.Find.Execute Replace:=wdReplaceAll

        .Text = "[^13]{2,}"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .MatchWildcards = True
    Selection.Find.Execute Replace:=wdReplaceAll

        .Text = "([^13] [^13]){1,}"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .MatchWildcards = True
    Selection.Find.Execute Replace:=wdReplaceAll

        .Text = "[ ]{2,}"
        .Replacement.Text = " "
        .Forward = True
        .Wrap = wdFindContinue
        .MatchWildcards = True
    Selection.Find.Execute Replace:=wdReplaceAll
    End With
End With
End Sub
Reply With Quote
  #2  
Old 03-21-2023, 07:45 PM
BrianHoard BrianHoard is offline Compile error -- incompatibility? Windows 10 Compile error -- incompatibility? Office 2019
Advanced Beginner
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

Possibly. What if you let this person running Word 2007 record a macro doing one of these tasks, and look at the result created in their version. You could also test your existing code by commenting out that line Word is complaining about to see if it runs without it. If you're lucky, that's the only problem.
Reply With Quote
  #3  
Old 03-23-2023, 10:26 AM
Ulodesk Ulodesk is offline Compile error -- incompatibility? Windows 10 Compile error -- incompatibility? Office 2021
Word 2013 Expert Cert
Compile error -- incompatibility?
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default

Thanks for your reply, which I passed on to the user. Here is his response. Any ideas?


I was able to get the macro to run by commenting out the following commands:

NumberSpacing = …
NumberForm = …
StylisticSet = …
ContextualAlternates = …
CollapseByDefault = …
For some reason my version of Word is not recognizing the syntax of these statements as valid.
Reply With Quote
  #4  
Old 03-23-2023, 10:46 AM
BrianHoard BrianHoard is offline Compile error -- incompatibility? Windows 10 Compile error -- incompatibility? Office 2019
Advanced Beginner
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

Okay, then my next thought is to have the person using Word 2007 record a macro that does all the things you need. They may need to do one of these finds at a time, and just keep grabbing the syntax of the code that is recorded by the macro. Once you have all of that, then we can look at what was recorded and see if we can optimize that to run as a script.
Reply With Quote
  #5  
Old 03-23-2023, 12:12 PM
Italophile Italophile is online now Compile error -- incompatibility? Windows 11 Compile error -- incompatibility? Office 2021
Expert
 
Join Date: Mar 2022
Posts: 315
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Is the document the macro is being run against in Compatibility Mode, or in Wd2003 format (.doc instead of .docx)?
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile error on hidden module Simss Excel Programming 2 09-25-2017 01:37 AM
compile error expected end sub ashg75 Word VBA 2 07-13-2017 07:08 AM
Compile error -- incompatibility? Compile error in Module ksigcajun Word VBA 2 04-08-2015 06:44 AM
Compile error: sub or function not defined.. xena2305 Excel Programming 0 08-02-2011 10:17 AM
compile error in Word raco Word 0 09-28-2010 12:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft