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
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