#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 281
Default Macro issue

Hi all,

i am just trying to count how many excel files are in each folders that i
want to process in them i try the code below but i got error " type miss
match" and my other question is that i want to activate the last tab in each
file that i open can any body help me on this?

Dim fs As Application.FileSearch
Set fs = Application.FileSearch
With fs
.LookIn = "L:\Toshiba\" & Trim(Str(j)) & "\" & kk
.Filename = "*.xls"
mmm = .FoundFiles.Count


thanks,
--
Farhad Hodjat
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro issue

Hi,

I don't understand how your setting up the path but you should be able to
modify this

Sub OpenFiles()
Dim FSO As Object
Dim Folder As Object
Dim File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("c:\") ' Change to suit
For Each File In Folder.Files
If File.Type = "Microsoft Excel Worksheet" Then
Count = Count + 1
End If
Next
MsgBox Count
End Sub

Mike

"Farhad" wrote:

Hi all,

i am just trying to count how many excel files are in each folders that i
want to process in them i try the code below but i got error " type miss
match" and my other question is that i want to activate the last tab in each
file that i open can any body help me on this?

Dim fs As Application.FileSearch
Set fs = Application.FileSearch
With fs
.LookIn = "L:\Toshiba\" & Trim(Str(j)) & "\" & kk
.Filename = "*.xls"
mmm = .FoundFiles.Count


thanks,
--
Farhad Hodjat

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 281
Default Macro issue

Thanks Mike! i made a little cahnge in your code and it worked but i still
need to know about my secod question which is that i want to know how can i
activate the last tab of each file that i open in my code the tabs names are
different and i don't know the name of tabs

Thanks again for your hehp!
--
Farhad Hodjat


"Mike H" wrote:

Hi,

I don't understand how your setting up the path but you should be able to
modify this

Sub OpenFiles()
Dim FSO As Object
Dim Folder As Object
Dim File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("c:\") ' Change to suit
For Each File In Folder.Files
If File.Type = "Microsoft Excel Worksheet" Then
Count = Count + 1
End If
Next
MsgBox Count
End Sub

Mike

"Farhad" wrote:

Hi all,

i am just trying to count how many excel files are in each folders that i
want to process in them i try the code below but i got error " type miss
match" and my other question is that i want to activate the last tab in each
file that i open can any body help me on this?

Dim fs As Application.FileSearch
Set fs = Application.FileSearch
With fs
.LookIn = "L:\Toshiba\" & Trim(Str(j)) & "\" & kk
.Filename = "*.xls"
mmm = .FoundFiles.Count


thanks,
--
Farhad Hodjat

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro issue

Hi,

The way I prefer is to use code to open the workbooks then call code to do
whatever you want in each workbook you open.

Sub OpenFiles()
Dim FSO As Object
Dim Folder As Object
Dim File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("c:\") ' Change to suit
For Each File In Folder.Files
If File.Type = "Microsoft Excel Worksheet" Then
Workbooks.Open Filename:=Folder.Path & "\" & File.Name

'Call your macro
dothings
ActiveWorkbook.Close True
End If
Next
End Sub


Sub dothings()
MsgBox ActiveWorkbook.Name
End Sub

Mike

"Farhad" wrote:

Thanks Mike! i made a little cahnge in your code and it worked but i still
need to know about my secod question which is that i want to know how can i
activate the last tab of each file that i open in my code the tabs names are
different and i don't know the name of tabs

Thanks again for your hehp!
--
Farhad Hodjat


"Mike H" wrote:

Hi,

I don't understand how your setting up the path but you should be able to
modify this

Sub OpenFiles()
Dim FSO As Object
Dim Folder As Object
Dim File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("c:\") ' Change to suit
For Each File In Folder.Files
If File.Type = "Microsoft Excel Worksheet" Then
Count = Count + 1
End If
Next
MsgBox Count
End Sub

Mike

"Farhad" wrote:

Hi all,

i am just trying to count how many excel files are in each folders that i
want to process in them i try the code below but i got error " type miss
match" and my other question is that i want to activate the last tab in each
file that i open can any body help me on this?

Dim fs As Application.FileSearch
Set fs = Application.FileSearch
With fs
.LookIn = "L:\Toshiba\" & Trim(Str(j)) & "\" & kk
.Filename = "*.xls"
mmm = .FoundFiles.Count


thanks,
--
Farhad Hodjat

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 281
Default Macro issue

Thanks again Mike for the second respond but i don't want to know the sheets
name i just want the last tab of each file been activated so i can get the
information that i need in this specific tab of each file. sorry i am very
new in VBA. please let me know if you can help me on this.

Regards,
--
Farhad Hodjat


"Mike H" wrote:

Hi,

The way I prefer is to use code to open the workbooks then call code to do
whatever you want in each workbook you open.

Sub OpenFiles()
Dim FSO As Object
Dim Folder As Object
Dim File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("c:\") ' Change to suit
For Each File In Folder.Files
If File.Type = "Microsoft Excel Worksheet" Then
Workbooks.Open Filename:=Folder.Path & "\" & File.Name

'Call your macro
dothings
ActiveWorkbook.Close True
End If
Next
End Sub


Sub dothings()
MsgBox ActiveWorkbook.Name
End Sub

Mike

"Farhad" wrote:

Thanks Mike! i made a little cahnge in your code and it worked but i still
need to know about my secod question which is that i want to know how can i
activate the last tab of each file that i open in my code the tabs names are
different and i don't know the name of tabs

Thanks again for your hehp!
--
Farhad Hodjat


"Mike H" wrote:

Hi,

I don't understand how your setting up the path but you should be able to
modify this

Sub OpenFiles()
Dim FSO As Object
Dim Folder As Object
Dim File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("c:\") ' Change to suit
For Each File In Folder.Files
If File.Type = "Microsoft Excel Worksheet" Then
Count = Count + 1
End If
Next
MsgBox Count
End Sub

Mike

"Farhad" wrote:

Hi all,

i am just trying to count how many excel files are in each folders that i
want to process in them i try the code below but i got error " type miss
match" and my other question is that i want to activate the last tab in each
file that i open can any body help me on this?

Dim fs As Application.FileSearch
Set fs = Application.FileSearch
With fs
.LookIn = "L:\Toshiba\" & Trim(Str(j)) & "\" & kk
.Filename = "*.xls"
mmm = .FoundFiles.Count


thanks,
--
Farhad Hodjat



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro issue

Hi,

That was just a line of code to demonstrate the workbook was open. To active
the last sheet use this line. You can then go on to do whatever you want.


Sub dothings()
Sheets(Worksheets.Count).Activate
End Sub

Mike
"Farhad" wrote:

Thanks again Mike for the second respond but i don't want to know the sheets
name i just want the last tab of each file been activated so i can get the
information that i need in this specific tab of each file. sorry i am very
new in VBA. please let me know if you can help me on this.

Regards,
--
Farhad Hodjat


"Mike H" wrote:

Hi,

The way I prefer is to use code to open the workbooks then call code to do
whatever you want in each workbook you open.

Sub OpenFiles()
Dim FSO As Object
Dim Folder As Object
Dim File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("c:\") ' Change to suit
For Each File In Folder.Files
If File.Type = "Microsoft Excel Worksheet" Then
Workbooks.Open Filename:=Folder.Path & "\" & File.Name

'Call your macro
dothings
ActiveWorkbook.Close True
End If
Next
End Sub


Sub dothings()
MsgBox ActiveWorkbook.Name
End Sub

Mike

"Farhad" wrote:

Thanks Mike! i made a little cahnge in your code and it worked but i still
need to know about my secod question which is that i want to know how can i
activate the last tab of each file that i open in my code the tabs names are
different and i don't know the name of tabs

Thanks again for your hehp!
--
Farhad Hodjat


"Mike H" wrote:

Hi,

I don't understand how your setting up the path but you should be able to
modify this

Sub OpenFiles()
Dim FSO As Object
Dim Folder As Object
Dim File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("c:\") ' Change to suit
For Each File In Folder.Files
If File.Type = "Microsoft Excel Worksheet" Then
Count = Count + 1
End If
Next
MsgBox Count
End Sub

Mike

"Farhad" wrote:

Hi all,

i am just trying to count how many excel files are in each folders that i
want to process in them i try the code below but i got error " type miss
match" and my other question is that i want to activate the last tab in each
file that i open can any body help me on this?

Dim fs As Application.FileSearch
Set fs = Application.FileSearch
With fs
.LookIn = "L:\Toshiba\" & Trim(Str(j)) & "\" & kk
.Filename = "*.xls"
mmm = .FoundFiles.Count


thanks,
--
Farhad Hodjat

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Excel Macro issue msofficehelp Excel Discussion (Misc queries) 2 October 24th 08 01:12 AM
Macro issue Sue Excel Discussion (Misc queries) 0 October 8th 08 08:05 PM
Macro Issue basanth New Users to Excel 3 September 10th 08 06:05 PM
AutoFill Macro Issue Jon Excel Discussion (Misc queries) 1 March 13th 08 02:19 PM
AutoFill Macro Issue Jon Excel Discussion (Misc queries) 1 March 13th 08 02:18 PM


All times are GMT +1. The time now is 07:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"