By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,967 Members | 1,710 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,967 IT Pros & Developers. It's quick & easy.

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

Lokean
P: 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
Share this Question
Share on Google+
5 Replies


SammyB
Expert 100+
P: 807
>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
P: 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
Expert 100+
P: 807
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
P: 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
Expert 100+
P: 807
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

Post your reply

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