A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Page Layout
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Show Folder index list in word document



 
 
Thread Tools Display Modes
  #11  
Old April 29th, 2008, 06:13 PM
lorne17 lorne17 is offline
Member
 
First recorded activity by OfficeFrustration: Apr 2008
Posts: 6
Default

Awesome thanks for the help. I figured out the bold too:

.Bold = True

I think we have it to our liking. If anyone knows how to make it automatic upon opening that would be best.

Thanks for the patience and help.

Lorne



Quote:
Originally Posted by Doug Robbins - Word MVP View Post
This line of code:

MyPath = "O:\Detail-Standards\Revit How To\Video Tutorials"

should be:

MyPath = "O:\Detail-Standards\Revit How To\Video Tutorials\"

That is, it must terminate in a path separator \
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"lorne17" wrote in message
...

I am so sorry to keep bothering you on this matter. I really appreciate
the help.

I tried replacing that code with: MyPath = "Drive:\Folder\"

But it doesn't work. When I place my path in there, it runs the macro
with no errors and acts as if it's working, and flashes the highlighted
selection in my table. But doesnt' insert any file names? Any reason
why this is?

This is what I have:


Sub Autonew()

ActiveDocument.Tables(1).Cell(1, 1).Select
Selection.Delete

Dim MyPath As String
Dim MyName As String

MyPath = "O:\Detail-Standards\Revit How To\Video Tutorials"

'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Do While MyName ""
Selection.InsertAfter MyName & vbCr
MyName = Dir
Loop

'collapse the selection
Selection.Collapse wdCollapseEnd

With ActiveDocument.Tables(1).Cell(1, 1).Range.Font
.Name = "Arial"
.Size = 10
End With

End Sub


With that said, what is wrong with it? Anything you see?

Also, regarding your suggestion for making this a template file. We'll
never need to use this macro on another file. I just wanted it to run
when I open the current document not a new document with this template
file. Does that make sense?

Also what's the code to make the font bold? I tried: .Style = Bold.
Didn't work :P

I assume, there is no way to make the file names in the list links to
each individual file?

Thanks again!! You really are a HUUUGE HELP

Lorne


Doug Robbins - Word MVP;2742110 Wrote:
Like I said, I would recommend that you save this document as a
template,
and create the
macro in the template and change its name to Sub Autonew()

Then when you create a new document from that template, the macro will
run.

To hard code the folder location, replace

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

with

MyPath = "Drive:\Folder\"

If you save the document as a template as I recommend, then you could
also
have a macro in that template that opened the selected file

Dim myfile As String

myfile = Selection.Paragraphs(1).Range.Text
Documents.Open "Drive\Folder\" & myfile

Where "Drive\Folder\" are the same as used in the code above.

To apply a particular font, use

With ActiveDocument.Tables(1).Cell(1, 1).Range.Font
.Name = "Arial"
.Size = 10
End With

Change the name of the font and the size to those that take your
fancy.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"lorne17"
wrote in message
...-

Ok,

Adding the new code to the macro worked. A couple issues though:

-It's not automatic when I open the file. How do I make it
automatic?
-How can I change my coding to automatically select a folder path?
Not
have the user select it (our folder location won't be changing).
-Also, can I have this list be linked to each individual file? That
way if the user clicks the name of the file, it will open that file.
-Have a set font/size for list? (is this part of the macro coding?)

Am I asking to much? It would be really nice for this to be this way
and not have to worry about it for future users in this file.

Thanks so much for your help and patience.

Lorne

Doug Robbins - Word MVP;2739908 Wrote:-
It can only be updated by deleting the existing list and running the
macro
again. How automatic do you need to make it?

While you could create a macro that ran automatically when the
document
was
opened, there must be some way of identifying the location of the
existing
list so that the macro can delete it and replace it.

One way would be to have the list created inside a one cell table
(without
borders if desired)

If that table was the first table in the document, adding the
following
code
at the beginning of the macro would delete the contents of that table
and
replace it with an updated list

ActiveDocument.Tables(1).Cell(1, 1).Select
Selection.Delete

I would recommend that you save this document as a template, and
create
the
macro in the template and change its name to Sub Autonew()

Then when you create a document from that template, the list will be
updated
each time.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

-




--
lorne17 -





--
lorne17
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:33 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.