I picked up a book on the basics of VBA. One of the examples the author gives is opening a document from the 'Recent Files' list. It is as follows:
("Absolute Beginner's Guide to VBA" - Paul McFedries. Pg. 113. Que Books. 1994)
[vba]Sub Main()
With RecentFiles(1)
Documents.Open .Path & "\" & .Name
End With
End Sub[/vba]
The author states if you want it to run automatically when Word starts, save the routine in a new module called AutoExec. This part I can intuitively understand. It's something that's going to automatically execute Word is opened. OK But I noticed a few pecularities.
One is that when I changed the macro name to something else say "OpenRecent_Files" for example, the macro does not get automatically triggered. Obviously the word Main itself has special meaning to VBA. Is it like naming a macro "AutoRun"? And are there other similar "trigger" words like it?
#2) Why is there a space in between .Open .Path???
#3) I don't understand why he has .Path and .Name. I thought that to get the property .Fullname provides you with both the document path & name.
So I changed his routine to:
[vba]Sub OpenRecent_Document()
With RecentFiles(1)
'Documents.Open .Path & "\" & .Name
Documents.Open .FullName
End With
End Sub[/vba]
And of course as a young grasshoppa - I was proven wrong! So what gives?