PDA

View Full Version : OrganizerCopy problem with Wd2003 and DMS



fionabolt
11-02-2007, 09:09 AM
Can anybody help with this problem.

When a document has been saved to a Document Management System, then the ActiveDocument.FullName becomes something curious specific to the DMS (and ActiveDocument.Path becomes empty).

Therefore the following code
Set aTemp = ActiveDocument.AttachedTemplate
Set aDoc = ActiveDocument
For Each styleLoop In ActiveDocument.Styles
If styleLoop = strStyleName Then
Application.OrganizerCopy Source:=aTemp.FullName, _
Destination:=aDoc.FullName, _
Name:=strStyleName, _
Object:=wdOrganizerObjectStyles
Exit For
End If
Next styleLoop

fails with error 4149 File Not Found.

Unfortnuately OrganizerCopy requires FullName for the destination (I tried just ActiveDocument but that fails too).

Has anyone encountered this problem? AND come up with a solution ;)

TonyJollans
11-02-2007, 10:01 AM
I came across a related problem recently with network files in Word 2007 and there is no solution I know of.

I haven't tried but it *may* be possible to work with the dialog rather than using organizercopy - I'm not very hopeful but I'd be interested to know if you do find a workaround.

fionabolt
11-05-2007, 04:26 AM
Thanks Tony,

A solution might be to use an ODMA API, does anyone out there know if this would work, or how I would go about doing this?

In the meantime, I've just applied a VERY simple solution (using the OpenasDocument function I determine all the formatting of the font object in the template and then apply the same formatting to the font object in the document):

Public Sub UpdateStyle(strStyleName As String)
Dim bDocProtected
Dim bTempsaved As Boolean
Dim aTemp As Document
Dim aDoc As Document
Dim fName, fSize, fBold As Boolean, fItalic As Boolean, fUL, fULCol, _
fST As Boolean, fDST As Boolean, fOut As Boolean, fEmb As Boolean, _
fShad As Boolean, fHide As Boolean, fAllCap As Boolean, fCol, _
fEng As Boolean, fSup As Boolean, fSub As Boolean, fScale As Long, _
fKern As Long, fAnim, fDCSG As Boolean, fEmp, fSizBi As Long, fNameBi, _
fboldBi As Boolean, fItalicBi As Boolean, fAutoUpdate As Boolean, fBase, fNextPara
'open the template so we can ascertain the
'formatting of the font object
Set aTemp = ActiveDocument.AttachedTemplate.OpenAsDocument
Set aDoc = ActiveDocument
'default to true
bDocProtected = True
'ascertain the protection status of the
'document and unprotect if necessary
If aDoc.ProtectionType = wdNoProtection Then
bDocProtected = False
Else
modMacros.unProtectDocument
End If
'determine if the open template is dirty
bTempsaved = aTemp.Saved
'ascertain the formatting of the font object
'from the template
With aTemp
On Error GoTo UpdateStyleErrHand
With .Styles(strStyleName).Font
fName = .Name
fSize = .Size
fBold = .Bold
fItalic = .Italic
fUL = .Underline
fULCol = .UnderlineColor
fST = .StrikeThrough
fDST = .DoubleStrikeThrough
fOut = .Outline
fEmb = .Emboss
fShad = .Shading
fHide = .Hidden
fAllCap = .AllCaps
fCol = .Color
fEng = .Engrave
fSup = .Superscript
fSub = .Subscript
fScale = .Scaling
fKern = Kerning
fAnim = .Animation
fDCSG = .DisableCharacterSpaceGrid
fEmp = .EmphasisMark
fSizBi = .SizeBi
fNameBi = .NameBi
fboldBi = .BoldBi
fItalicBi = .ItalicBi
End With
fAutoUpdate = .AutomaticallyUpdate
fBase = .BaseStyle
fNextPara = .NextParagraphStyle
End With
StyleLoopAgain:
'apply the formatting of the font object
'to the stlye in the document
For Each styleLoop In aDoc.Styles
On Error GoTo UpdateStyleErrHand
If styleLoop = strStyleName Then
With aDoc.Styles(strStyleName)
With .Font
.Name = fName
.Size = fSize
.Bold = fBold
.Italic = fItalic
.Underline = fUL
.UnderlineColor = fULCol
.StrikeThrough = fST
.DoubleStrikeThrough = fDST
.Outline = fOut
.Emboss = fEmb
.Shading = fShad
.Hidden = fHide
.AllCaps = fAllCap
.Color = fCol
.Engrave = fEng
.Superscript = fSup
.Subscript = fSub
.Scaling = fScale
.Kerning = fKern
.Animation = fAnim
.DisableCharacterSpaceGrid = fDCSG
.EmphasisMark = fEmp
.SizeBi = fSizBi
.NameBi = fNameBi
.BoldBi = fboldBi
.ItalicBi = fItalicBi
End With
.AutomaticallyUpdate = fAutoUpdate
.BaseStyle = fBase
.NextParagraphStyle = fNextPara
End With
'we have found the style and applied the formatting
'so skip style.add
GoTo StyleFound
Exit For
End If
Next styleLoop
'style does not exist in document
'so add it
aDoc.Styles.Add (strStyleName)
GoTo StyleLoopAgain
StyleFound:
'return the document to the same protected
'status as we found it
If bDocProtected = True Then
modMacros.ProtectDocument (ActiveDocument)
End If
'close the template document with the
'same dirty status as when we opened it
aTemp.Saved = bTempsaved
aTemp.Close
Exit Sub
UpdateStyleErrHand:
Resume Next
End Sub