how do you insert the filename without the extension into the header.
> how do you insert the filename without the extension into the header.
What are you having trouble with -- stripping the extension off the
filename, or adding text to the header?
--
Working without a .NET?
http://classicvb.org/
Laura G - 23 Nov 2005 18:09 GMT
stripping the extension
> > how do you insert the filename without the extension into the header.
>
[quoted text clipped - 3 lines]
> Working without a .NET?
> http://classicvb.org/
Karl E. Peterson - 23 Nov 2005 19:51 GMT
>>> how do you insert the filename without the extension into the
>>> header.
[quoted text clipped - 3 lines]
>
> stripping the extension
BaseFileName = Left$(FileName, InStrRev(FileName, ".") - 1)
--
Working without a .NET?
http://classicvb.org/
Hi Laura,
If you are wanting to use the FILENAME field to do this, then no, you can't
omit the filename extension.
if you want to use VBA to insert the text of the filename as text, then
ActiveDocument.Name returns the filename, and you can use the instrRev
function to find the position of the last period in the name, and then use
the Left$ function to trim the string to the appropriate length before
inserting it.

Signature
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
> how do you insert the filename without the extension into the header.
Laura G - 23 Nov 2005 18:26 GMT
that's exactly what i need...but i'm not familar with that function. point
me in the right direction?
> Hi Laura,
>
[quoted text clipped - 8 lines]
>
> > how do you insert the filename without the extension into the header.
Laura G - 23 Nov 2005 18:30 GMT
Actually, I would like to use everything to the LEFT of a specific word.
Will not always be in same location though...
> Hi Laura,
>
[quoted text clipped - 8 lines]
>
> > how do you insert the filename without the extension into the header.
Jonathan West - 23 Nov 2005 19:42 GMT
Try this
strName = ActiveDocument.Name
strName = Left$(strName, InstrRev(strName, ".") - 1)

Signature
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
> Actually, I would like to use everything to the LEFT of a specific word.
> Will not always be in same location though...
[quoted text clipped - 13 lines]
>>
>> > how do you insert the filename without the extension into the header.
Karl E. Peterson - 23 Nov 2005 19:49 GMT
> Actually, I would like to use everything to the LEFT of a specific
> word. Will not always be in same location though...
In that case, assuming SomeText is the variable that holds the original
string...
nPos = Instr(SomeText, SpecificWord)
If nPos Then
WhatYouWant = Left$(SomeText, nPos - 1)
End If
--
Working without a .NET?
http://classicvb.org/
Jonathan West - 23 Nov 2005 19:56 GMT
Hi Karl,
To get the last occurrence (instead of the first) of SpecificWord, you need
to use InstrRev, not Instr...

Signature
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
>> Actually, I would like to use everything to the LEFT of a specific
>> word. Will not always be in same location though...
[quoted text clipped - 10 lines]
> Working without a .NET?
> http://classicvb.org/
Karl E. Peterson - 23 Nov 2005 20:34 GMT
> Hi Karl,
>
> To get the last occurrence (instead of the first) of SpecificWord,
> you need to use InstrRev, not Instr...
Whoops, of course. Typed too fast. (At least I got it right in one post.)
Thanks... Karl
--
Working without a .NET?
http://classicvb.org/
>>> Actually, I would like to use everything to the LEFT of a specific
>>> word. Will not always be in same location though...
[quoted text clipped - 10 lines]
>> Working without a .NET?
>> http://classicvb.org/