PDA

View Full Version : Opening a website in Word



marcow
09-28-2005, 10:46 AM
Hello,

My website creates invoices. I open these invoices in Word, so I can edit and save them.
To make this proces easy, someone made a script for it:
Sub mijnmacro()
Dim oDoc As Word.Document
Dim iCnt As Integer

iCnt = Val(InputBox("welke bestanden openen?", "Save Word document", 1))
If iCnt >= 1 Then

Set oDoc = Application.Documents.Open _
(FileName:="http://www.mijnsite.nl/admin/invoice.php?oID=" & CStr(iCnt) & ".htm")

With oDoc
.PageSetup.Orientation = wdPortrait
.SaveAs "E:\facturen\f" & CStr(iCnt) & ".doc"
End With

Set oDoc = Nothing
End If
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=2, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
End Sub

This worked perfectly, until I moved my site to a new host. Since then I'm getting a error 5151, invalid path or document name.

(By the way, the acces to the website has a htaccess password protection)

I've been trying a lot of things:
Sub inlog()
'
' inlog Macro
' Macro opgenomen op 27-09-2005 door Marco
'
Documents.Open FileName:="http://www.mysite.nl/admin", _
ConfirmConversions:=False, ReadOnly:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
wdOpenFormatAuto
End Sub
This one works. A window appears asking me for username and password. After this the (index) website is shown.

Sub inlog()
'
' inlog Macro
' Macro opgenomen op 27-09-2005 door Marco
'
Documents.Open FileName:="http://www.mysite.nl/admin/invoice.php?oID=1600", _
ConfirmConversions:=False, ReadOnly:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
wdOpenFormatAuto
End Sub

This one gives the same 5151 error. But when I click on Word, document open, and put http://www.mysite.nl/admin/invoice.php?oID=1600 there, the invoice opens.

Anybody got an idea?

Thanks,

Marco

MOS MASTER
09-29-2005, 02:18 PM
Hi and Welcome to VBAX Marco! :hi: (Leuk je hier te zien)

Seams you've tracked me down from Helpmij forum in Holland to here! :rofl: (I was the one providing this you this macro on a dutch forum a while ago)

I'll try out your macro and will try to give you a good answer asap. :whistle:

marcow
09-30-2005, 12:02 AM
Hi Joost,

Seems like I found the right person. : pray2: You really helped me out by writing the macro. :thumb But since I moved my website to another host, I get an error.

The extra work that I got has driven me crazy, so I'm trying to get it to work.
Since last week I've found a workaround:
I open the first invoice manually, using document, open.
Then when I'm logged in, the invoice is in Word.

After this, the original macro works.
So it has to do something with the htacces file I think.

Groeten,

Marco

MOS MASTER
09-30-2005, 03:58 PM
Hi Marco, :yes

I revisited your original question today at the dutchforum and tried out the first link you gave me. (Without the invoice number)...the one you posted as a test.

This one still works...Isn't that one in the protected area by any chance?

Then I tried out one of your links with a invoice number and of course I could duplicate the problem cause I wasn't alloud to get in. (Security wise)

This will probable take a lot of guesses from my side cause obviously I can't access your site like you can and therefore am not able to test properly! :(

Could you restate your Work arround sollution in More detail? Perhaps I can pick something up that we can program.

Another question if you log in first in your site and then run the macro does that make any change? (Same error?)

I'll do my very best to help you Marco but for now I'm not sure if we can bypass security.....:whistle: