Pulling document title from a document not currently opened in wor

C

Cameron Powell

I have a feeling that this should be a really simple question, but I just
can't figure it out for the life of me. I want to have a template window that
lists all files in our networked templates directory, and shows them by title
with the icon. Just like when you click templates >> On My Computer from the
New Document Task Pane. How would I accomplish pulling the title from a
document that isn't opened. Here is the code I am using that isnt working.
Perhaps you will see what it is I am trying to do.

Sub GetTitle()
Dim Fname As Document
Set Fname = Documents("C:\BSMBCG.doc")
ftitle = Fname.BuiltInDocumentProperties(wdPropertyTitle)
Selection.InlineShapes.AddOLEObject ClassType:="Word.Document.8",
FileName _
:="C:\BSMBGC.doc", _
LinkToFile:=False, DisplayAsIcon:=True, IconFileName:= _

"C:\WINDOWS\Installer\{91130409-6000-11D3-8CFE-0150048383C9}\wordicon.exe" _
, IconIndex:=1, IconLabel:=ftitle
End Sub

I have tried numerous combinations and can't seem to come up with anything.
I keep getting Run-time error 4160. Bad File Name.
Set Fname = Documents("C:\BSMBCG.doc") this is the line that highlights upon
clicking debug.

I have checked to make sure the location is correct, and it is. Can someone
please help me!
 
J

Jonathan West

Jay Freedman said:
I think you're on the wrong track. See
http://www.word.mvps.org/FAQs/MacrosVBA/DSOFile.htm for a better way.

I've just learned that Microsoft have updated the dsofile.dll file on their
website, so the ListProps download with that article no longer works. I've
prepared a new one and it should hopefully be up on the site in a day or
two.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
C

Cameron Powell

Thanks for that article, but that doesn't seem to work. Even using the same
version of DSOfile.dll that you used I still get errors. Perhaps maybe there
is a different route I could take altogether.

My goal is to display templates in our networked templates folder. I know
that I could just change my default templates directory to the network
directory but at that point I would have all of the default word templates
there too which I dont want. Also I would like to be able to have my
templates organized in to tabs much like it is already with the default word
templates.

If anyone has any advice at all, please don't hesitate to reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top