#1   Report Post  
Posted to microsoft.public.excel.programming
aw aw is offline
external usenet poster
 
Posts: 19
Default VB error

Would like to know the correct statement that make the following VB works


Sub import01()

Dim hfile(1 To 8), i As Integer

hfile1 = "T:\Abc\Consolid\htmPL\PLY.HTM"
hfile2 = "T:\Abc\Consolid\htmPL\PLB.HTM"
hfile3 = "T:\Abc\Consolid\htmPL\PLL.HTM"
hfile4 = "T:\Abc\Consolid\htmPL\PLPP.HTM"
hfile5 = "T:\Abc\Consolid\htmPL\PLR.HTM"
hfile6 = "T:\Abc\Consolid\htmPL\PLT.HTM"
hfile7 = "T:\Abc\Consolid\htmPL\PLSMHK.HTM"
hfile8 = "T:\Abc\Consolid\htmPL\PLSMH.HTM"

For i = 1 To 8

Workbooks.Open Filename:=hfile(i)

... vb code
... vb code
... vb code


Next

End sub



--
aw
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default VB error

Sub import01()

Dim hfile(7), i As Integer

hfile(0) = "T:\Abc\Consolid\htmPL\PLY.HTM"
hfile(1) = "T:\Abc\Consolid\htmPL\PLB.HTM"
hfile(2) = "T:\Abc\Consolid\htmPL\PLL.HTM"
hfile(3) = "T:\Abc\Consolid\htmPL\PLPP.HTM"
hfile(4) = "T:\Abc\Consolid\htmPL\PLR.HTM"
hfile(5) = "T:\Abc\Consolid\htmPL\PLT.HTM"
hfile(6) = "T:\Abc\Consolid\htmPL\PLSMHK.HTM"
hfile(7) = "T:\Abc\Consolid\htmPL\PLSMH.HTM"

For i = 0 To 7

Workbooks.Open Filename:=hfile(i)

'.. vb code
'.. vb code
'.. vb code

Next

End Sub

hth

Carlo


On Dec 13, 12:53 pm, aw wrote:
Would like to know the correct statement that make the following VB works

Sub import01()

Dim hfile(1 To 8), i As Integer

hfile1 = "T:\Abc\Consolid\htmPL\PLY.HTM"
hfile2 = "T:\Abc\Consolid\htmPL\PLB.HTM"
hfile3 = "T:\Abc\Consolid\htmPL\PLL.HTM"
hfile4 = "T:\Abc\Consolid\htmPL\PLPP.HTM"
hfile5 = "T:\Abc\Consolid\htmPL\PLR.HTM"
hfile6 = "T:\Abc\Consolid\htmPL\PLT.HTM"
hfile7 = "T:\Abc\Consolid\htmPL\PLSMHK.HTM"
hfile8 = "T:\Abc\Consolid\htmPL\PLSMH.HTM"

For i = 1 To 8

Workbooks.Open Filename:=hfile(i)

.. vb code
.. vb code
.. vb code

Next

End sub

--
aw


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default VB error

While the Dim statement 'carlo' showed you is one way to do it (although his
code assume the default Option Base of 0), your Dim statement is fine too.

I'm a little surprised you got the assignment statements wrong given you
used the array syntax correctly later on inside your For-Next loop. The key
to working with arrays comes from the structure of the Dim statement... the
array name followed by an opening parenthesis, followed by and index number
followed by a closing parenthesis... you use this structure for assignments
as well as for accessing the contents of a particular element of an array.
So, your assignment statements should look like this....

hfile(1) = "T:\Abc\Consolid\htmPL\PLY.HTM"
hfile(2) = "T:\Abc\Consolid\htmPL\PLB.HTM"
hfile(3) = "T:\Abc\Consolid\htmPL\PLL.HTM"
etc.

One thing you may want to consider though.... declaring your array with a
data type. As you wrote it, the array will be Variants... but since you are
assigning String values to the array, it would be more efficient to declare
the array as data type String....

Dim hfile(1 To 8) As String, i As Integer

Rick


"aw" wrote in message
...
Would like to know the correct statement that make the following VB works


Sub import01()

Dim hfile(1 To 8), i As Integer

hfile1 = "T:\Abc\Consolid\htmPL\PLY.HTM"
hfile2 = "T:\Abc\Consolid\htmPL\PLB.HTM"
hfile3 = "T:\Abc\Consolid\htmPL\PLL.HTM"
hfile4 = "T:\Abc\Consolid\htmPL\PLPP.HTM"
hfile5 = "T:\Abc\Consolid\htmPL\PLR.HTM"
hfile6 = "T:\Abc\Consolid\htmPL\PLT.HTM"
hfile7 = "T:\Abc\Consolid\htmPL\PLSMHK.HTM"
hfile8 = "T:\Abc\Consolid\htmPL\PLSMH.HTM"

For i = 1 To 8

Workbooks.Open Filename:=hfile(i)

.. vb code
.. vb code
.. vb code


Next

End sub



--
aw


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default VB error

Hey Rick

thanks for writing the additional Information.

Just a question though:

he was talking about VB, so does it really matter if he assigns a Data
Type or not?
I thought VB only works with Variants, regardless on which Data Type
you work with!
Please correct me if I'm wrong.

thanks

Carlo

On Dec 13, 3:43 pm, "Rick Rothstein \(MVP - VB\)"
wrote:
While the Dim statement 'carlo' showed you is one way to do it (although his
code assume the default Option Base of 0), your Dim statement is fine too.

I'm a little surprised you got the assignment statements wrong given you
used the array syntax correctly later on inside your For-Next loop. The key
to working with arrays comes from the structure of the Dim statement... the
array name followed by an opening parenthesis, followed by and index number
followed by a closing parenthesis... you use this structure for assignments
as well as for accessing the contents of a particular element of an array.
So, your assignment statements should look like this....

hfile(1) = "T:\Abc\Consolid\htmPL\PLY.HTM"
hfile(2) = "T:\Abc\Consolid\htmPL\PLB.HTM"
hfile(3) = "T:\Abc\Consolid\htmPL\PLL.HTM"
etc.

One thing you may want to consider though.... declaring your array with a
data type. As you wrote it, the array will be Variants... but since you are
assigning String values to the array, it would be more efficient to declare
the array as data type String....

Dim hfile(1 To 8) As String, i As Integer

Rick

"aw" wrote in message

...



Would like to know the correct statement that make the following VB works


Sub import01()


Dim hfile(1 To 8), i As Integer


hfile1 = "T:\Abc\Consolid\htmPL\PLY.HTM"
hfile2 = "T:\Abc\Consolid\htmPL\PLB.HTM"
hfile3 = "T:\Abc\Consolid\htmPL\PLL.HTM"
hfile4 = "T:\Abc\Consolid\htmPL\PLPP.HTM"
hfile5 = "T:\Abc\Consolid\htmPL\PLR.HTM"
hfile6 = "T:\Abc\Consolid\htmPL\PLT.HTM"
hfile7 = "T:\Abc\Consolid\htmPL\PLSMHK.HTM"
hfile8 = "T:\Abc\Consolid\htmPL\PLSMH.HTM"


For i = 1 To 8


Workbooks.Open Filename:=hfile(i)


.. vb code
.. vb code
.. vb code


Next


End sub


--
aw- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default VB error

VB, as does VBA, works with data types, it is VBScript that uses all
variants.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"carlo" wrote in message
...
Hey Rick

thanks for writing the additional Information.

Just a question though:

he was talking about VB, so does it really matter if he assigns a Data
Type or not?
I thought VB only works with Variants, regardless on which Data Type
you work with!
Please correct me if I'm wrong.

thanks

Carlo

On Dec 13, 3:43 pm, "Rick Rothstein \(MVP - VB\)"
wrote:
While the Dim statement 'carlo' showed you is one way to do it (although
his
code assume the default Option Base of 0), your Dim statement is fine
too.

I'm a little surprised you got the assignment statements wrong given you
used the array syntax correctly later on inside your For-Next loop. The
key
to working with arrays comes from the structure of the Dim statement...
the
array name followed by an opening parenthesis, followed by and index
number
followed by a closing parenthesis... you use this structure for
assignments
as well as for accessing the contents of a particular element of an
array.
So, your assignment statements should look like this....

hfile(1) = "T:\Abc\Consolid\htmPL\PLY.HTM"
hfile(2) = "T:\Abc\Consolid\htmPL\PLB.HTM"
hfile(3) = "T:\Abc\Consolid\htmPL\PLL.HTM"
etc.

One thing you may want to consider though.... declaring your array with a
data type. As you wrote it, the array will be Variants... but since you
are
assigning String values to the array, it would be more efficient to
declare
the array as data type String....

Dim hfile(1 To 8) As String, i As Integer

Rick

"aw" wrote in message

...



Would like to know the correct statement that make the following VB
works


Sub import01()


Dim hfile(1 To 8), i As Integer


hfile1 = "T:\Abc\Consolid\htmPL\PLY.HTM"
hfile2 = "T:\Abc\Consolid\htmPL\PLB.HTM"
hfile3 = "T:\Abc\Consolid\htmPL\PLL.HTM"
hfile4 = "T:\Abc\Consolid\htmPL\PLPP.HTM"
hfile5 = "T:\Abc\Consolid\htmPL\PLR.HTM"
hfile6 = "T:\Abc\Consolid\htmPL\PLT.HTM"
hfile7 = "T:\Abc\Consolid\htmPL\PLSMHK.HTM"
hfile8 = "T:\Abc\Consolid\htmPL\PLSMH.HTM"


For i = 1 To 8


Workbooks.Open Filename:=hfile(i)


.. vb code
.. vb code
.. vb code


Next


End sub


--
aw- Hide quoted text -


- Show quoted text -






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default VB error

Sorry, my bad.

Thanks for telling me.

Carlo


On Dec 13, 5:48 pm, "Bob Phillips" wrote:
VB, as does VBA, works with data types, it is VBScript that uses all
variants.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"carlo" wrote in message

...



Hey Rick


thanks for writing the additional Information.


Just a question though:


he was talking about VB, so does it really matter if he assigns a Data
Type or not?
I thought VB only works with Variants, regardless on which Data Type
you work with!
Please correct me if I'm wrong.


thanks


Carlo


On Dec 13, 3:43 pm, "Rick Rothstein \(MVP - VB\)"
wrote:
While the Dim statement 'carlo' showed you is one way to do it (although
his
code assume the default Option Base of 0), your Dim statement is fine
too.


I'm a little surprised you got the assignment statements wrong given you
used the array syntax correctly later on inside your For-Next loop. The
key
to working with arrays comes from the structure of the Dim statement...
the
array name followed by an opening parenthesis, followed by and index
number
followed by a closing parenthesis... you use this structure for
assignments
as well as for accessing the contents of a particular element of an
array.
So, your assignment statements should look like this....


hfile(1) = "T:\Abc\Consolid\htmPL\PLY.HTM"
hfile(2) = "T:\Abc\Consolid\htmPL\PLB.HTM"
hfile(3) = "T:\Abc\Consolid\htmPL\PLL.HTM"
etc.


One thing you may want to consider though.... declaring your array with a
data type. As you wrote it, the array will be Variants... but since you
are
assigning String values to the array, it would be more efficient to
declare
the array as data type String....


Dim hfile(1 To 8) As String, i As Integer


Rick


"aw" wrote in message


...


Would like to know the correct statement that make the following VB
works


Sub import01()


Dim hfile(1 To 8), i As Integer


hfile1 = "T:\Abc\Consolid\htmPL\PLY.HTM"
hfile2 = "T:\Abc\Consolid\htmPL\PLB.HTM"
hfile3 = "T:\Abc\Consolid\htmPL\PLL.HTM"
hfile4 = "T:\Abc\Consolid\htmPL\PLPP.HTM"
hfile5 = "T:\Abc\Consolid\htmPL\PLR.HTM"
hfile6 = "T:\Abc\Consolid\htmPL\PLT.HTM"
hfile7 = "T:\Abc\Consolid\htmPL\PLSMHK.HTM"
hfile8 = "T:\Abc\Consolid\htmPL\PLSMH.HTM"


For i = 1 To 8


Workbooks.Open Filename:=hfile(i)


.. vb code
.. vb code
.. vb code


Next


End sub


--
aw- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


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
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM


All times are GMT +1. The time now is 11:13 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"