PDA

View Full Version : Saveas target url



Cyberbuddy
07-07-2006, 03:21 PM
I have the following problem.:banghead:
When I create a document from sharepoint, It is innitiated through activeX. Then when I click on the save button, the saveas dialog perfectly opens the url,from which it was created. The thing is that I have to get this url in VBA when it opens. Somewhere office "knows" where it got is , but I can't find the right property.
Can anyone help me??

fumei
07-08-2006, 12:24 AM
I don't know SharePoint at all. Could you clarify something? You state:
when I click on the save button, the saveas dialog perfectly opens the url,from which it was created. This is different from normal Word behaviour. When I click on Save...it saves. Are you saying if you click on Save...you get SaveAs?

Here are some suggestions for trying to find the URL - as you are perfectly correct. Word MUST know where it is from if it can prefill it in the SaveAs dialog.

ActiveDocument.Path
ActiveDocument.FullName

Cyberbuddy
07-08-2006, 01:49 AM
The document is being created by an activeX :
objEditor = new ActiveXObject(strProgID + ".2");
if (!objEditor.CreateNewDocument2(window, strTemplate, strSaveLocation))


As you can see the strSaveLocation is passed on to word but when I use :
ActiveDocument.Path
ActiveDocument.FullName
is only gives: document1
Although the path is unknown (because it is a new document) it knows the path when I click on the save button. ans yes indeed it opens the save as dialog.
Any ideas?

fumei
07-08-2006, 04:35 AM
If you are able to see the code with strSaveLocation...why can't you get that value?

Can you explain?
The thing is that I have to get this url in VBA when it opens. WHY do you need this?

Cyberbuddy
07-08-2006, 04:42 AM
strSaveLocation is not an VBA Word variable but it is passed to Word in javascript. This is a default sharepoint action which can not be changed.

I need the path so I can use it in a userform, which gets extra information based on this path. this path is an URL to a Team site. In this teamsite there are document libraries which contain specific information about the teamsite. This information (e.g. Business adress) has to be inserted in the document BEFORE it is saved to the documentlibrarie

fumei
07-08-2006, 10:49 AM
It has to be passed as SOME VBA variable, as Word has to put in the SaveAs dialog. Hmmmm. As this is SharePoint, you are using 2003, yes? Unfortunately, I do not use 2003...specifically because of SharePoint...which we don't have...so why have 2003?

Hmmm. Try looping through all DocumentVariables, and see if it is there. It HAS to be somewhere.

Cyberbuddy
07-08-2006, 02:53 PM
Is there an easy way to loop throug all the possible variables in a word document. I did something like that with the document properties, but there wasn't any relation to the URL.

(nice sculptures by the way!)

The problem is, that I can determine the path AFTER the document is saved, and I need it BEFORE

fumei
07-10-2006, 11:11 PM
Yes, you can loop through variables.Sub ShowVars()
Dim oVariable As Word.Variable
Dim oProperty As Object
Dim i As Integer

If ActiveDocument.Variables.Count > 0 Then
For Each oVariable In ActiveDocument.Variables
MsgBox oVariable.Name & " " & oVariable.Value
Next
End If
On Error Resume Next
For Each oProperty In ActiveDocument.BuiltInDocumentProperties
MsgBox oProperty.Name & " " & oProperty.Value
Next
End SubYou need the On Erroe Resume Next because the collections holds ALL application builtin properties and some only apply within specific apps. So trying to get a value for NumberOfSlides (when looping through all properties) will return an error in Word, or Excel etc.

You can also try looking to see if there are any Custom Document Properties.

You know, though....it may be hidden from us. There are LOTS of things that go on within Office apps that are not exposed to VBA. It could very well be something within SharePoint services that is not exposed. That seems bizarre to me, but then....it IS Microsoft.

MOS MASTER
07-11-2006, 09:19 AM
As you can see the strSaveLocation is passed on to word but when I use :
ActiveDocument.Path
ActiveDocument.FullName
is only gives: document1
Although the path is unknown (because it is a new document) it knows the path when I click on the save button. ans yes indeed it opens the save as dialog.
Any ideas?

Hi, :hi:

This is very strange!

It's normal for a new document to return "document1" on calling .Fullname cause it wil get its full path after you save it for the first time.

But the thing that baffles me is the fact you say: "it knows the path when I click on the save button"

I can't see how that's possible (other than automation in the Word doc itself). You say this is a document created in a Webbased interface. Well the normal thing to do for a browser is to download a copy of the document on the server on the clientside. (what you see in your browser) that is normal.

And when you click save you should get the saveas dialog cause it's the first time you save the document. Hence the fact that that document hasn't been saved before.. If it would have been saved by the javascript code the .Fullname property would be filled with the path and the document would do a Save action instead of the SaveAs action...

What Word does do is rember where you saved your last document. So it will go to the right target folder when you press Save. (On startup it will go to the save folder that you've set in Word | Options)

Perhaps Word remembering the path is the file path you've been looking for?

Perhaps this is the variabel you're looking for:
Options.DefaultFilePath(Path:=wdDocumentsPath)
Just guessing btw!

HTH. :whistle:

Cyberbuddy
07-11-2006, 01:44 PM
Unfortunally it is not in the variables. (Thanks Fumei)
It is also not in the options (that gives d:\my documents)

It has nothing to do with the location where I saved my last document (I've tested that)

I even checked the register and the url is there AFTER I have saved the document.

I don't know where to look further, Anyone?

MOS MASTER
07-11-2006, 01:58 PM
Hi, :D

Perhaps you can try the path for the attached template:
MsgBox ActiveDocument.AttachedTemplate.FullName


Succes! :whistle:

Cyberbuddy
07-11-2006, 02:10 PM
Joost, that is the funny part. When I do that it perfectly gives:
http://sharepoint/algemeen/sjablonen/sjabloon.dot

But this is unfortunally not the url of the doclib where I create the document. :sad2:

Cyberbuddy
07-11-2006, 02:13 PM
Maybe a total different approach. I noticed that when I create a document, in the history of IE there is a cookie discovery.asmx
When I look in this file I see at the end the documentlibrary. Perhaps I can read out this cookie???

MOS MASTER
07-11-2006, 02:22 PM
I've got one more property for you to test and then I'm all out of VBA trics! :p


Msgbox VBProject.FileName

MOS MASTER
07-11-2006, 02:26 PM
Maybe a total different approach. I noticed that when I create a document, in the history of IE there is a cookie discovery.asmx
When I look in this file I see at the end the documentlibrary. Perhaps I can read out this cookie???

Well with php you could propably read out that cookie (or any other webscripting language)

I do wonder however what this function does: objEditor.CreateNewDocument2

You pass the rootpath to the function but we can't see what that function does. Perhaps you can put that function over here so we can see exactly what it does. I have no problem reading Javascript.

HTH. :whistle:

Cyberbuddy
07-11-2006, 02:43 PM
Here is the total function

function createNewDocumentWithProgID(strTemplate, strSaveLocation, strProgID, bXMLForm)
{
var objEditor;
var L_NewDocumentRuntimeError_Text;
var L_NewDocumentError_Text;
var fRefreshOnNextFocus = false;
if (document.forms[0].ChooseTemplate)
{
strTemplate = document.forms[0].ChooseTemplate.value;
}

if (bXMLForm)
{
var L_NewDocumentRuntimeError_Text = L_NewFormLibTb1_Text;
var L_NewDocumentError_Text = L_NewFormLibTb2_Text;
}
else
{
var L_NewDocumentRuntimeError_Text = L_NewDocLibTb1_Text;
var L_NewDocumentError_Text = L_NewDocLibTb2_Text;
}
try
{
if (!objEditor.CreateNewDocument2(window, strTemplate, strSaveLocation))
{
alert(L_NewDocumentRuntimeError_Text);
}

fRefreshOnNextFocus = objEditor.PromptedOnLastOpen();
if (fRefreshOnNextFocus)
{
window.onfocus = RefreshOnNextFocus;
}
else
{
SetWindowRefreshOnFocus();
}
return;
}
catch (e)
{
}
try
{
objEditor = new ActiveXObject(strProgID + ".1");
window.onfocus = null;
if (!objEditor.CreateNewDocument(strTemplate, strSaveLocation))
alert(L_NewDocumentRuntimeError_Text);
SetWindowRefreshOnFocus();
return;
}
catch (e)
{
alert(L_NewDocumentError_Text);
}
}

with the "

Msgbox VBProject.FileName " is says path unknown

MOS MASTER
07-11-2006, 03:00 PM
Hi, :yes

That function is a global functions which has the 2 most important functions (for creating a document) in it they are:

objEditor.CreateNewDocument(strTemplate, strSaveLocation) and:

CreateNewDocument2(window, strTemplate, strSaveLocation)

The function you've posted does not create the Word file but It holds the above two subs that do!

So could you look up the above 2 functions that create the Word docs and post them here? (Lets hope there aren't any more nested functions) :whip

Cyberbuddy
07-11-2006, 03:28 PM
Joost, I have searched all the files on the server and there is NO CreateNewDocument in any of the files.
Can it be a commando to the activeX ?

MOS MASTER
07-11-2006, 03:31 PM
Joost, I have searched all the files on the server and there is NO CreateNewDocument in any of the files.
Can it be a commando to the activeX ?

Could it be.. It's for sure a function of the ActiveX control. :)

I thought you where the developper of that control that's why I pressumed you had the source code of that control...

O well we'll look further in the morning going to bed now.

Welterusten. :whistle: