473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

I'm getting an error with filesearch object (office.core)

Lokean
71
At the top of my module I have

Imports Microsoft.Office.Core
Imports VBA

Public Function rpu_process_files(Optional ByVal sFolderString As String = "", _
Optional ByVal sSearchString As String = "", _
Optional ByVal sInExt As String = "", _
Optional ByVal sInPart As String = "", _
Optional ByVal iList As Integer = 0) As Integer



Dim fs3 As Microsoft.Office.Core.FileSearch
fs3.newsearch()



the program errors out at

fs3.newsearch()

"Object reference not set to instance of an object."

what am I doing wrong?
Apr 19 '07 #1
5 2355
SammyB
807 Expert 512MB
>what am I doing wrong?
I suspect you need a New

But, what you are really doing wrong is not using the Net Framework classes. Why not use System.IO.Directory.GetFiles?
Apr 19 '07 #2
Lokean
71
>what am I doing wrong?
I suspect you need a New

But, what you are really doing wrong is not using the Net Framework classes. Why not use System.IO.Directory.GetFiles?
When I use a 'new' I get

"New cannot be used on an interface"


as to your question, I am trying to flip a vba program into VB.net without recoding it from scratch.

I have a user form where the user can select any of the MSOFiletypes from a listbox.
Apr 19 '07 #3
SammyB
807 Expert 512MB
When I use a 'new' I get

"New cannot be used on an interface"


as to your question, I am trying to flip a vba program into VB.net without recoding it from scratch.

I have a user form where the user can select any of the MSOFiletypes from a listbox.
Assuming you are using Excel:
Expand|Select|Wrap|Line Numbers
  1. Imports Microsoft.Office.Core
  2. Imports Excel
  3. .
  4. .
  5. .
  6. Dim fs As Microsoft.Office.Core.FileSearch
  7. Dim xlApp As New Excel.Application
  8. fs = xlApp.FileSearch
  9.  
Apr 19 '07 #4
Lokean
71
actually,

I am using VB.net.

I'm trying to convert a program I wrote in MS Excel into a vb.net standalone.
Apr 19 '07 #5
SammyB
807 Expert 512MB
actually,

I am using VB.net.

I'm trying to convert a program I wrote in MS Excel into a vb.net standalone.
That what I thought. My code above was written in VB.NET. You have to add a COM reference to the Microsoft Excel Object Library, so that you can use the Excel.Application object to get the FileSearch. Your migration is going to be difficult. --Sam
Apr 19 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mark | last post by:
Can anyone please tell me why the following code works fine in Win98/Access97, but fails to recognize files with a ".zip" extension in WinXP/Access2002/2000? It correctly lists the name of each...
2
by: Simon | last post by:
Overnight, I've developed this error somehow, when I try to build/run my application: "Parser Error Message: Unable to load file 'Interop.Microsoft.Office.Core'." I'm pretty sure I haven't...
1
by: ns2k | last post by:
I add reference office.dll and Microsoft Office Excel Component to my project and use : --------------------------------------- Dim App As Excel.Application, BarName as String ... Dim Bar As...
0
by: Mads Westen | last post by:
Hi, I'm trying to code a application that can create a new email in Outlook I have coded my project in VS 2003, but now I have upgraded to VS 2005. I can not build my project anymore, I get a...
19
by: Alan Carpenter | last post by:
Access 8 on Win98 and WinXP I'm having trouble with wildcards in the .Filename property of the FileSearch Object giving different results on win98 and XP. I've been successfully using...
0
by: nithya176 | last post by:
Hey guys..i jus thought if u cud help me out wit this error im gettin. Im writing a c# code to create an add-in in visio using VSTO. I found this code which was in VB and i'm tryin to convert it to...
6
by: nagar | last post by:
I need to get the list of Autocorrect entries in word. Is there a way to do it without connecting to Word? Is the list saved somewhere? If I need to connect to Word, how can I detect if it's...
3
by: MLH | last post by:
With Application.FileSearch .NewSearch .LookIn = "C:\My Documents" .SearchSubFolders = True .FileName = "Run" .MatchTextExactly = True .FileType = msoFileTypeAllFiles End With My code pukes...
2
by: Sun | last post by:
Hi guys, I have a problem which troubled me last two weeks. I create a web applicatoin using VS2005 to generate the powerpoint presentation. All works fine in my local machine but after I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.