Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attach active Docs Open document to email

Status
Not open for further replies.

djames2173

Technical User
Nov 17, 2006
6
US
I have created a memo form in MS Word and have VBA macro coding for when users complete an input form which inputs the information into bookmarks of the document. There is also a macro button that i have used VBA code to attach the active, saved document to the email. The problem is that this code is only attaching the document if it is saved within Windows Explorer and not if it is saved in Docs Open 4.0 [Document Management System]. It seems that the ActiveDocument.Path is returing empty appearing as if the document was not saved. Also the ActiveDocument.FullName is appearing with the ODMA path. Oh yeah, the integration for Docs & MS Word 2003 uses ODMA. Below is the code i am using. Any help is greatly appreciated.

Private Sub cmdSendEmemo_Click()

'''Don't forget to set a reference to the Outlook object library 8.0
Dim sEmailAddress As String
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem


On Error Resume Next
'''this checks to see if the active document has been saved at least once
If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

'''go to EmailAddress bookmark to get e-mail addresses for email
Selection.GoTo What:=wdGoToBookmark, Name:="EmailAddress"
sEmailAddress = Selection.Text

With oItem
'''this is where the stored e-mail address is used for populating the message
.To = sEmailAddress
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
DisplayName:="Document as attachment"

End With

oItem.Display

If bStarted Then
oOutlookApp.Quit
End If

'''clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
 
Not sure what else to suggest, as it is correct that the Path and FullName require a Word save. So I think you are stuck with that.

You do not need to actually select the bookmark and get the text. In fact, it is generally a good idea to avoid using the Selection.
Code:
sEmailAddress = ActiveDocument.Bookmarks("EmailAddress").Range.Text

I don't know what ODMA is.


Gerry
My paintings and sculpture
 
Than you, fumei, for the tip on using the text in the bookmarks. I believe what i am looking for is the actual method that i need to get into the way Docs Open calls the document path/name from the file server.

As for ODMA: The Open Document Management API (ODMA) simplifies integration and interoperability of standard desktop applications with document management systems.

Hopefully there is someone out there familiar with doing this. Thank again for your advice.
 
I guess so. But until you actually save the file, there IS no document path/filename. The file server has no file yet. Once it is saved, then ActiveDocument Path, and FullName work as usual. Docs Open may have its own method of calling a file from the server, but if it is not ON the server yet, then it is not on the server yet.

If I understand correctly, you seem to talking about a document in Word that is not saved yet. If it is not saved yet, there is no file on the server.
The problem is that this code is only attaching the document if it is saved within Windows Explorer
I do not see that Windows Explorer has anything to do with it. It needs to be saved in/by Word.

Are you saying that you can use Docs Open to save a document (to an actual file location), and it still shows as Document 1 on the title bar - ie. it is NOT saved yet by Word?

Gerry
My paintings and sculpture
 
The document actually has been saved and is present on the server. The problem is that with the code i have, it is appearing with an empty ActiveDocument.Path [=""], but when i save the file outside of the DM [i.e. Windows Explorer], the ActiveDocument.Path is NOT empty [="H:\<homeshare>\<directory>"]. As well, the ActiveDOcument.FullName is appearing with ODMA:\\... with the document that is saved in the DM.
 
i save the file outside of the DM [i.e. Windows Explorer],
Sorry, I must be very dense. WHAT has Windows Explorer have to do with it? I asked this before.

If Word does not know it is saved, then Word can hardly return as path and filename, now can it?

Are you telling me that you are somehow saving the file in Windows Explorer? Please tell me how you do that, and NOT be saving the file in Word?

Again, what has Windows Explorer have to do with this???

Please describe step by step what is going on.

You state the file is saved on the server. Saved by what process, if it is not saved by Word? As far as I know, a NEW Word document can not be saved by Windows Explorer.

It almost sounds like you are talking about an existing template file that is double clicked in Windows Explorer - which in fact would NOT open the file, but clone a new file - which would (until you save it IN WORD) have no path, or filename.

Again, what is with you mentioning Windows Explorer?

Gerry
My paintings and sculpture
 
I mention windows explorer because the point i am trying to get across is that if i save the document outside of a document management system [C:\Temp], all works well. maybe this mention of windows explorer is not necessary.

If the document is saved using a document management system [Docs Open], the code acts as if the document is not saved at all. When stepping throught the code it shows ActiveDocument.Path = "" and ActiveDocument.FullName = "::ODMA\PCDOCS\Folder1\Folder2\Folder3". If the document is saved with words native save[save as] when stepping throught the code it shows ActiveDocument.Path = "C:\temp" and ActiveDocument.FullName = "New.doc". I apologize if this is not makeing sense to you; sometimes it is difficult to put these things into words.
 
ActiveDocument.Path uses the Windows common dialog API so it will not return what you need. Seems to me that you would have to access the document through a ODMA API.
 
Thank you CBasic. This is what I have bene trying to get at. IF Docs Open has a method of saving a file that is independent of using native Word methods, then sure, the file is saved I guess. But as far as Word is concerned - because it does use the Windows API - NOTHING has changed. There is still no file saved.

So any calls made through Word/Windows API will return nothing.

Frankly, I think this is a bit strange, and could lead to possible problems. It seems to imply that you could have a readable file (saved by DOCS OPEN) that could be different from a readable file (saved by Word/Windows). Hmmmm. That shouts version control issues to me. It would seem only sensible, IMO, that any method used by Docs Open that saves a file, would also make sure that Word/Windows becomes aware of it. Apparently not. Seems bad to me.
If the document is saved using a document management system [Docs Open], the code acts as if the document is not saved at all.
So if this is true - that Docs Open actually, really, for sure, saves a document to disk and bypasses and update to Windows...yeah, you have a problem with any code you may be trying to run in Word/Windows.

Gerry
My paintings and sculpture
 
fumei,

I would say ODMA is more like a database of documents. To access the database you have to have access to the objects in the database. Windows can't access the database because the database objects are not part of the Windows object model.
 
That may be so, but I am not sure how relevant it is to the issue raised. It may be true that Windows can not access the database information, but the issue is - is the file actually saved to disk?

If it is truly saved to disk that it HAS TO be interacting with the Windows file system. That is unless it somehow creates its own file system. I don't mean its own information about the file system. If there is I/O, and the file is written to disk, then AFAIK, Windows has to know about it. Or should. It is certainly possible that Docs Open writes the file to disk, and Windows does know about it, but there should be a callback to Word that the file is now saved.

The point being is that while Windows may not have access to the database objects, those database objects are not the same as the file system objects. And if a file is actually saved to disk, then that disk object should be known to Windows. Which it very well may be. However, the issue is the code being executed in Word. Windows may know of the file system object, but if there is no information passed back to Word - which it seems there is not - then Word does not know the file is saved. Therefore...no path.

Again, I would say that if a third party application takes an active Word document, and saves it to disk (and as a Word file!) independently of Word, then it is pretty rude programming for it to not let Word know.
To access the database you have to have access to the objects in the database. Windows can't access the database because the database objects are not part of the Windows object model.
The issue is accessing file system information, not the database information. If the file is actually saved to disk, then that disk information (path and name) IS part of the Windows object model.

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top