Newbie needs advice on project 
Author Message
 Newbie needs advice on project

In an attempt to make my clients lives easier I recently put together some
very simple macro buttons within an Excel sheet.

However, these were liked so much that I am now being asked to do a similar
exercise on another project, although this time it is slightly more
complex - which is why I am here.

Basically the situation is this :

- I have a 1 page template in Word which will be used as a summary page for
submitting suggestions.

- It is likely that we will have perhaps 100 or more of these sheets, and it
has been asked if I could create an Index page which will read a couple of
fields (e.g. the Title of the suggestion) from each summary page and then
list them.

- From the Index page you should be able to click on the Title you are
interested in and be taken to the full page summary.

- Each time a new suggestion is added the index will update itself.

Not sure what the best way to approach this is.  Should I have 1 large Word
file to which I keep adding new pages when a new suggestion is received (it
will be text only so shouldn't grow too large), or should I have a directory
devoted to this, with separate Word files for each summary and one for the
Index etc.....

Any advice appreciated (and if anyone has any code to do this it would be
even better).

Many thanks

Andrew



Sun, 11 Jul 2004 19:04:24 GMT  
 Newbie needs advice on project
I have a similar situation were I have approx 250 pieces of equipment
that each have a Word inventory sheet.  I created a Word table and
have a link for each file.  I hacked this out.

Not tested. Not responsible for what it might do.

Using Word97.

Sub CreateSuggestionIndex()
'This assumes One table, three columns, headers inplace
'This macro is run from the three column table
Dim NewSuggPath$, SuggestPath$
Dim Temp$, SuggArray$()
Dim tbl As Table
Dim rng As Selection.Range

'I would keep the index doc file in C:\IdxSugg
NewSuggPath$ = "C:\IdxSugg\NewSugg\"
SuggestPath$ = "C:\IdxSugg\Suggest\"

Temp$ = Dir(NewSuggPath$ + "*.doc")
Do
If Temp$ <> "" Then
    Counter = Counter + 1
    ReDim Preserve SuggArray$(Counter)
    SuggArray$(Counter) = Temp$
    Temp$ = Dir
End If
Loop Until Temp$ = ""

Set tbl = ActiveDocument.Tables(1)

For A = 1 To Counter

Documents.Open FileName:=SuggArray$(A)

SuggName$ = Documents(SuggArray$).FormFields(1).Result
SuggAuthor$ = Documents(SuggArray$).FormFields(2).Result

Documents(SuggArray$).Close savechanges = wdDoNotSaveChanges

'Add row at bottom of table
Selection.EndOf unit:=wdTable
Selection.MoveRight Count:=1
Selection.InsertRows 1

RowI = ActiveDocument.Tables(1).Rows.Count

tbl.Cell(RowI, 1).Range.Text = SuggName$
tbl.Cell(RowI, 2).Range.Text = SuggAuthor$
Set CurCell = tbl.Cell(RowI, 3).Select
Selection.Start = Selection.End

'insert hyperlink.
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
        SuggestPath$ + SuggArray$(A), SubAddress:=""

'move files
Name NewSuggPath$ + SuggArray$(A) As SuggestPath$ + SuggArray$(A)
Next

End Sub



Mon, 12 Jul 2004 06:02:01 GMT  
 Newbie needs advice on project
David,

Many thanks for the code.
I am a complete novice when it comes to VB so I will look though  it and try
and understand what is happening.

I do have one problem with it not running, but I wonder if that is to do
with using Word 97 rather than the more recent versions which use VBA.

Perhaps yourself or someone else could help.
It throws back an error message

"Expected Function or Variable"

on the line

Set CurCell = tbl.Cell(RowI, 3).Select

with ".Select" being the problem area.

Any ideas ?

Many thanks

Andrew

Quote:
> I have a similar situation were I have approx 250 pieces of equipment
> that each have a Word inventory sheet.  I created a Word table and
> have a link for each file.  I hacked this out.

> Not tested. Not responsible for what it might do.

> Using Word97.

> Sub CreateSuggestionIndex()
> 'This assumes One table, three columns, headers inplace
> 'This macro is run from the three column table
> Dim NewSuggPath$, SuggestPath$
> Dim Temp$, SuggArray$()
> Dim tbl As Table
> Dim rng As Selection.Range

> 'I would keep the index doc file in C:\IdxSugg
> NewSuggPath$ = "C:\IdxSugg\NewSugg\"
> SuggestPath$ = "C:\IdxSugg\Suggest\"

> Temp$ = Dir(NewSuggPath$ + "*.doc")
> Do
> If Temp$ <> "" Then
>     Counter = Counter + 1
>     ReDim Preserve SuggArray$(Counter)
>     SuggArray$(Counter) = Temp$
>     Temp$ = Dir
> End If
> Loop Until Temp$ = ""

> Set tbl = ActiveDocument.Tables(1)

> For A = 1 To Counter

> Documents.Open FileName:=SuggArray$(A)

> SuggName$ = Documents(SuggArray$).FormFields(1).Result
> SuggAuthor$ = Documents(SuggArray$).FormFields(2).Result

> Documents(SuggArray$).Close savechanges = wdDoNotSaveChanges

> 'Add row at bottom of table
> Selection.EndOf unit:=wdTable
> Selection.MoveRight Count:=1
> Selection.InsertRows 1

> RowI = ActiveDocument.Tables(1).Rows.Count

> tbl.Cell(RowI, 1).Range.Text = SuggName$
> tbl.Cell(RowI, 2).Range.Text = SuggAuthor$
> Set CurCell = tbl.Cell(RowI, 3).Select
> Selection.Start = Selection.End

> 'insert hyperlink.
> ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
>         SuggestPath$ + SuggArray$(A), SubAddress:=""

> 'move files
> Name NewSuggPath$ + SuggArray$(A) As SuggestPath$ + SuggArray$(A)
> Next

> End Sub



Mon, 12 Jul 2004 17:17:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Need advice for Web Services Project.

2. (2nd Post) BASIC programming advice needed: PKWARE'S compression utilities front end application - PROGRAMMING PROJECT

3. Need advice on a Project

4. Help/Advice Needed for College Project

5. Need advice on project

6. New VB / IE Project Advice Needed

7. Newbie Needs Advice For Purchase

8. Need newbie advice please

9. Client / Server newbie needs some advice

10. Newbie Needs Your Advice

11. Newbie needs advice

12. Newbie: need some advice

 

 
Powered by phpBB® Forum Software