Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2023, 04:33 PM
savvy savvy is offline compile error with checkabort Windows 10 compile error with checkabort Office 2019
Novice
compile error with checkabort
 
Join Date: Aug 2020
Location: Toronto
Posts: 17
savvy is on a distinguished road
Default compile error with checkabort

I get a compile error in msword: method or data member not found

I tried checking the box for Excel Object Library in tools references but cannot debug code:



Sub abc()
Dim restart As Boolean
restart = True
While restart
SendKeys "{NUMLOCK}{ADD}"
Dim key As String
key = ""
While key = ""
DoEvents
If Application.CheckAbort = True Then Exit Sub
If Not Application.CommandBars.GetPressedMso("FilePrint") Is Nothing Then Exit Sub
key = Application.CommandBars.FindControl(ID:=30002).acc Child(1).Caption
Wend
If key = vbCr Then
Call xyz
restart = False
ElseIf key = "{NUMLOCK}{ADD}" Then
'Do nothing, restart loop
Else
restart = False
End If
Wend
End Sub

Not sure how to fix the error.
Reply With Quote
  #2  
Old 05-02-2023, 06:35 PM
Guessed's Avatar
Guessed Guessed is offline compile error with checkabort Windows 10 compile error with checkabort Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,966
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I don't know the aims of your macro but I would remove this line because that doesn't exist in Word.
If Application.CheckAbort = True Then Exit Sub

Then the GetPressedMso only works with ToggleButtons eg Bold. I don't see FilePrint as being a toggle button. As far as I can tell, it will return a Boolean value and can't be Nothing so I get a type error with that line if it points at a togglebutton.

Maybe you should explain what exactly you are trying to do. You won't find many people that like to use SendKeys short of giving up on all the alternatives first.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile error -- incompatibility? Ulodesk Word VBA 4 03-23-2023 12:12 PM
compile error expected end sub ashg75 Word VBA 2 07-13-2017 07:08 AM
compile error with checkabort 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 05:57 AM.


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