Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2007

Tip: Looking for answers? Try searching our database.

Save Document oddity

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Graham Mayor - 25 Jun 2007 07:31 GMT
I have used macros similar to the following to insert (in this instance) the
path at the foot of a document. However testing this in Word 2007 has thrown
up an anomaly in that the check for whether the document is saved is
completely ignored inevitably causing an error at the line pPathname= if the
document has not already been saved.

This always worked in Word 2003, however on testing again in Word 2003 (my
PC currently has both Word 2003 and 2007 installed in parallel) it no longer
worked there either.

Following a reboot, it worked again in 2003, but not in 2007, and then on
closing 2007 and reopening 2003 it no longer works there. Reboot and open
2007 without first opening 2003 and it still doesn't work :(

Initially I thought that the presence of both versions was the problem, but
my laptop only has 2007 and it doesn't work there either. Any ideas?

I am trying to like 2007 ..... honest .... but it seems to throw up one
problem after another.

On an entirely different note my laptop's Word 2007 has an AddIns tab on the
Ribbon, that of my desktop doesn't. My desktop has Acrobat 8.1 instead. I
guess that may be getting in the way, in the inimitable manner Adobe has of
screwing with Word :( ?

Sub InsrtPath()
Dim pPathname As String
Dim pFoldername As String
   With ActiveDocument
       If Not .Saved Then
           .Save
       End If
       pPathname = Left$(.FullName, (Len(.FullName) - Len(.Name) - 1))
       pFoldername = Right$(pPathname, (Len(pPathname) -
InStrRev(pPathname, "\")))
   End With
   Selection.TypeText pPathname
End Sub

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Graham Mayor - 25 Jun 2007 07:45 GMT
Testing further
Sub Saved()
If ActiveDocument.Saved = False Then _
MsgBox ("Not Saved")
If ActiveDocument.Saved = True Then _
MsgBox ("Saved")
End Sub
always shows 'Saved' here and if I run 2007 before 2003 it always shows
Saved there too. If I reboot, Word 2003 alone responds correctly?

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> I have used macros similar to the following to insert (in this
> instance) the path at the foot of a document. However testing this in
[quoted text clipped - 34 lines]
>    Selection.TypeText pPathname
> End Sub
Graham Mayor - 25 Jun 2007 08:22 GMT
While I am still talking to myself, I have found a workaround

       If Len(.Path) = 0 Then
           .Save
       End If

for the saved test,
(and before anyone comments I do know about  .path for the original macro -
it was just part of an example)

but I am still puzzled by the original failure.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Testing further
> Sub Saved()
[quoted text clipped - 45 lines]
>>    Selection.TypeText pPathname
>> End Sub
Jeff Mathewson - 25 Jun 2007 13:42 GMT
What it sounds like is depending on what version of Word you are opening
first, the VB object for that version is loading in memory and sticking.
Being on my first cup of coffee here I can't help, but you may need to
manually init the VB object.  In VB Editor check to see what references are
loaded.

Jeff
OJD

> While I am still talking to myself, I have found a workaround
>
[quoted text clipped - 57 lines]
> >>    Selection.TypeText pPathname
> >> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.