Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

WORD 2007 macro error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Letts - 04 Oct 2006 15:34 GMT
I have several WORD 2003 macros.

Now I'm trying out WORD 2007, I find that some of these no longer work - the
macro statements return ' error 5111 - this command is not available '.

example statement is:   With Application.FileSearch
       
FileSearch is still listed as a valid Application property on the help
pages. Have some of these been removed or disabled ?
zkid - 05 Oct 2006 21:10 GMT
Would you please provide the full chunk of code?

We need to see what it is that you're attempting to accomplish,

In the meantime, I seem to recall that I had trouble with
Application.FileSearch in VBA 2003 but not in XP, so I substituted the
following code in its place.  I'm REALLY shortcutting it here with a message
box so you can see how it works.  Of course, you would need to substitute
your code to either fill an array or list box, depending on what you're
attempting to do with it:

Dim myFile, strFolder As String, iCount As Integer

'Due to the way 2007 names files, you need to keep the asterisk after the
extension.  This will also work in all other versions of Word (after 95, that
is).

strFolder = "c:\TheFolderToSearch\*.doc*"  'For all files, use *.*.  

iCount = 0

myFile = Dir$(strFolder)
Do While myFile <> ""
   iCount = iCount + 1
   MsgBox myFile
   myFile = Dir$
Loop

If iCount = 0 Then MsgBox "No Word files were found in the following
location:  " & strFolder

> I have several WORD 2003 macros.
>
[quoted text clipped - 5 lines]
> FileSearch is still listed as a valid Application property on the help
> pages. Have some of these been removed or disabled ?
Chris Letts - 09 Oct 2006 09:59 GMT
yes I can easily substitue new code - that's not the point though - it means
I have to re-write many existing macros. The help pages say that these SHOULD
work, but they don't.

here is some code (which works fine in WORD 2003):

Sub insert_pic()
'
' insert_pic Macro
' Macro recorded 27/09/2006 by Administrator
'
Dim student As String

With Application.FileSearch
   .NewSearch
   .LookIn = "E:\speech"
   .SearchSubFolders = False
   .FileName = "*.jpg"
   

   If .Execute() > 0 Then
       
       For i = 1 To .FoundFiles.Count
       
          Selection.InlineShapes.AddPicture FileName:=.FoundFiles(i),
LinkToFile:=False, SaveWithDocument:=True
       
       student = .FoundFiles(i)
       howlong1 = Len(.LookIn)
       howlong2 = Len(student)
     
       
       student = Right$(student, howlong2 - howlong1 - 1)
       howlong2 = Len(student)
       student = Left$(student, howlong2 - 4)
       
       
       Selection.TypeText Text:=student
       
       Selection.MoveRight Unit:=wdCell
       
       Next i
   Else
       MsgBox "There were no files found."
   End If
End With

   
End Sub

> Would you please provide the full chunk of code?
>
[quoted text clipped - 36 lines]
> > FileSearch is still listed as a valid Application property on the help
> > pages. Have some of these been removed or disabled ?
Cindy M. - 09 Oct 2006 10:11 GMT
Hi =?Utf-8?B?Q2hyaXMgTGV0dHM=?=,

FileSearch is definitely being removed from Office 2007. The reasoning is that
file searching is part of the Operating System (Vista) and doesn't belong in
individual applications. The old "Dir" command should still work.

> I have several WORD 2003 macros.
>  
[quoted text clipped - 5 lines]
> FileSearch is still listed as a valid Application property on the help
> pages. Have some of these been removed or disabled ?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
Chris Letts - 09 Oct 2006 10:53 GMT
I guessed as much, however the help pages need updating - they still list
that as a valid function.......

> Hi =?Utf-8?B?Q2hyaXMgTGV0dHM=?=,
>
[quoted text clipped - 19 lines]
> This reply is posted in the Newsgroup; please post any follow question or reply
> in the newsgroup and not by e-mail :-)
Cindy M. - 30 Nov 2006 16:54 GMT
Hi =?Utf-8?B?Q2hyaXMgTGV0dHM=?=,

> I guessed as much, however the help pages need updating - they still list
> that as a valid function.......

Not anymore (after the release of RTM)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.