Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
Is there a way to make Constants as Arrays? Something like: Public Const Doc(1) As String = "Rules.DOC" Public Const Doc(2) As String = "Personal.DOC" Public Const Doc(3) As String = "Reporting.DOC" etc... Currently I'm using: Public Const Doc_01 As String = "Rules.DOC" Public Const Doc_02 As String = "Personal.DOC" Public Const Doc_03 As String = "Reporting.DOC" ....but that doesn't allow me to run through the documents in a loop, like a For-To-Next. Any suggentions? TIA, |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Charlotte,
You could do something like this Sub sonic() Dim WordApp As Object, WordDoc As Object Set WordApp = CreateObject("Word.Application") mypath = "C:\" MyArr = Array("Rules.doc", "Personal.doc", "Reporting.doc") For x = LBound(MyArr) To UBound(MyArr) WordApp.documents.Open mypath & MyArr(x) WordApp.Visible = True 'do things Next End Sub Mike "Charlotte E" wrote: Hello, Is there a way to make Constants as Arrays? Something like: Public Const Doc(1) As String = "Rules.DOC" Public Const Doc(2) As String = "Personal.DOC" Public Const Doc(3) As String = "Reporting.DOC" etc... Currently I'm using: Public Const Doc_01 As String = "Rules.DOC" Public Const Doc_02 As String = "Personal.DOC" Public Const Doc_03 As String = "Reporting.DOC" ....but that doesn't allow me to run through the documents in a loop, like a For-To-Next. Any suggentions? TIA, |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Const cDOCS As String = "Rules.doc\Personal.doc\Reporting.doc"
Sub test() Dim v For Each v In Split(cDOCS, "\") MsgBox v, , "For Each" Next ' or Dim i As Long, arr arr = Split(cDOCS, "\") For i = 0 To UBound(arr) MsgBox arr(i), , "For i =" Next End Sub Regards, Peter T "Charlotte E" <@ wrote in message ... Hello, Is there a way to make Constants as Arrays? Something like: Public Const Doc(1) As String = "Rules.DOC" Public Const Doc(2) As String = "Personal.DOC" Public Const Doc(3) As String = "Reporting.DOC" etc... Currently I'm using: Public Const Doc_01 As String = "Rules.DOC" Public Const Doc_02 As String = "Personal.DOC" Public Const Doc_03 As String = "Reporting.DOC" ...but that doesn't allow me to run through the documents in a loop, like a For-To-Next. Any suggentions? TIA, |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I might misunderstand the meaning of Charlotte's "To make Constants as
Arrays". But I can change elements of the constant array(arr). I wonder this could be called as a constant array. Const cDOCS As String = "Rules.doc\Personal.doc\Reporting.doc" Sub test() Dim i As Long, arr arr = Split(cDOCS, "\") For i = 0 To UBound(arr) MsgBox arr(i), , "For i = " & i Next For i = 0 To UBound(arr) arr(i) = Replace(UCase(arr(i)), "R", "A") Next For i = 0 To UBound(arr) MsgBox arr(i), , "After Modifing For i = " & i Next End Sub Keiji Peter T wrote: Const cDOCS As String = "Rules.doc\Personal.doc\Reporting.doc" Sub test() Dim v For Each v In Split(cDOCS, "\") MsgBox v, , "For Each" Next ' or Dim i As Long, arr arr = Split(cDOCS, "\") For i = 0 To UBound(arr) MsgBox arr(i), , "For i =" Next End Sub Regards, Peter T "Charlotte E" <@ wrote in message ... Hello, Is there a way to make Constants as Arrays? Something like: Public Const Doc(1) As String = "Rules.DOC" Public Const Doc(2) As String = "Personal.DOC" Public Const Doc(3) As String = "Reporting.DOC" etc... Currently I'm using: Public Const Doc_01 As String = "Rules.DOC" Public Const Doc_02 As String = "Personal.DOC" Public Const Doc_03 As String = "Reporting.DOC" ...but that doesn't allow me to run through the documents in a loop, like a For-To-Next. Any suggentions? TIA, |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Oh, yeah...
This is the way to do it - thanks, Peter :-) Peter T wrote: Const cDOCS As String = "Rules.doc\Personal.doc\Reporting.doc" Sub test() Dim v For Each v In Split(cDOCS, "\") MsgBox v, , "For Each" Next ' or Dim i As Long, arr arr = Split(cDOCS, "\") For i = 0 To UBound(arr) MsgBox arr(i), , "For i =" Next End Sub Regards, Peter T "Charlotte E" <@ wrote in message ... Hello, Is there a way to make Constants as Arrays? Something like: Public Const Doc(1) As String = "Rules.DOC" Public Const Doc(2) As String = "Personal.DOC" Public Const Doc(3) As String = "Reporting.DOC" etc... Currently I'm using: Public Const Doc_01 As String = "Rules.DOC" Public Const Doc_02 As String = "Personal.DOC" Public Const Doc_03 As String = "Reporting.DOC" ...but that doesn't allow me to run through the documents in a loop, like a For-To-Next. Any suggentions? TIA, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Wierd names defined as arrays of constants?!? | Excel Discussion (Misc queries) | |||
Wierd names defined as arrays of constants?!? | Excel Discussion (Misc queries) | |||
Trouble with arrays (transferring values between two arrays) | Excel Programming | |||
Working with ranges in arrays... or an introduction to arrays | Excel Programming | |||
Arrays - declaration, adding values to arrays and calculation | Excel Programming |