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 / July 2005

Tip: Looking for answers? Try searching our database.

HTTP Posting Document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
turp1twin - 26 Jul 2005 23:48 GMT
I am new to VBA and Word macros in general and have a question. Is it
possible to HTTP Post the ActiveDocument to a URL after it has been closed or
saved? Perhaps in the autoClose method? Since I am new to Word automation I
am having a hard time finding the answer from the Document object docs. I
have found examples of how to POST arbitrary data from the Document, but not
the entire binary Document itself. Any help would be appreciated. Cheers!

Signature

Jeff

moi - 27 Jul 2005 06:33 GMT
I experimented a little with this (instead of HTTP post, I use FTP), but
when I try to send an ActiveDocument to my webspace, just nothing happens. I
can only get it to work when sending another file which is not open. So yes,
if you create a DocumentClose-event which opens another doc with the macro
and FTP the saved file from there, it should work.

Here's my code.

Option Explicit

Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet
As Long) As Integer
Private Declare Function InternetConnect Lib "wininet.dll" Alias
"InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As
String, ByVal nServerPort As Integer, ByVal sUserName As String, ByVal
sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal
lContext As Long) As Long
Private Declare Function InternetOpen Lib "wininet.dll" Alias
"InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal
sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As
Long
Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA"
(ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal
lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long)
As Boolean

Private Sub FTPUploadDocument()
   Dim hConn As Long, hAndle As Long
   Dim ftpSrv, ftpUsr, ftpPwd As String
   ftpSrv = "ftp.server.here"
   ftpUsr = "ur_id"
   ftpPwd = "ur_pass"
   hAndle = InternetOpen("WinWord FTP Demo", 0, vbNullString, vbNullString,
0)
   hConn = InternetConnect(hAndle, ftpSrv, 21, ftpUsr, ftpPwd, 1, IIf(True,
&H8000000, 0), 0)
   FtpPutFile hConn, "file.doc", "uploaded.doc", &H1, 0
   InternetCloseHandle hConn
   InternetCloseHandle hAndle
End Sub

>I am new to VBA and Word macros in general and have a question. Is it
> possible to HTTP Post the ActiveDocument to a URL after it has been closed
[quoted text clipped - 5 lines]
> not
> the entire binary Document itself. Any help would be appreciated. Cheers!
turp1twin - 27 Jul 2005 18:36 GMT
Thanks for your response. I was hoping to avoid having to go the file system.
I guess if that is my only option I will have to try it. Thanks again for
your help. Cheers!

Signature

Jeff

> I experimented a little with this (instead of HTTP post, I use FTP), but
> when I try to send an ActiveDocument to my webspace, just nothing happens. I
[quoted text clipped - 46 lines]
> > not
> > the entire binary Document itself. Any help would be appreciated. Cheers!
 
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.