Search the Community
Showing results for tags 'network drive'.
-
I got an error when I try to save a .doc file using _Word_DocSave() function. Going deep to understand why this function fail in my case I ended up thinking it might be an unexpected behavior of that function because this function check if $oDoc.FullName if a file on disk but this is a little bit tricky. In my case I have a SharePoint farm where I can upload files (especially .doc and .docx). SharePoint save this files as blob in database but there is a feature that let you view them with explorer. So I can enter in explorer a link like http://mysharepointfarm/bla/bla/ and in this location I can see all .doc files. So far so good, Because I cannot use _Word_Open with a link but I can as a file path, I came up with the idea to map a network drive so http://mysharepointfarm/bla/bla/ became K:\mydocfiles. Now things are interesting, _Word_Open works fine as I expected and any other _Word_* functions works well also except _Word_Save whici fail with error code 2 because $oDoc.FullName doesn't return the network drive location used as parameter for _Word_Open but instead returns the address of mapped location (ex: http://mysharepointfarm/bla/bla/myfile.doc) so FileExists won't find a find at this location. I think this issue can be reproduced in other cases involving mapped drives, not just this one and in my oppinion this validation is not perfect. Maybe there should be a precheck to verify the drive type or something like that. I fixed my code with a custom function that skip this validation but what do you think, is this something that need to be reported as bug and fixed or do you consider this to be a very special case? This is the function about are we talking about. Func _Word_DocSave($oDoc) ; Error handler, automatic cleanup at end of function Local $oError = ObjEvent("AutoIt.Error", "__Word_COMErrFunc") #forceref $oError If Not IsObj($oDoc) Then Return SetError(1, 0, 0) If Not FileExists($oDoc.FullName) Then Return SetError(2, 0, 0) $oDoc.Save() If @error Then Return SetError(3, @error, 0) Return 1 EndFunc