Transfer PDF file to ftp server in MS access 2007 - vb6

I'm attempting to upload a pdf file to an ftp server. I've tried this by accessing the wininet dll but unsuccessfully.
What is the best way to do this in MS Access 2007 VB6? I can call a .net dll, but that is my last resort.
Thank you in advance.

If you mean VB6 then there's a control you can use for FTP functions. Go to Project/Components and add the "Microsoft Internet Transfer Control" to your project. It's fairly easy to use, but something like...
Inet.UserName = "Username"
Inet.Password = "Password"
Inet.Protocol = icFTP
Inet.RemoteHost = "123.123.123.123"
Inet.Execute , "put " & sFileToTransfer & " " & sFilenameOnRemoteHost
While Inet.StillExecuting
DoEvents
Wend
Check Inet.ResponseCode when it finishes
If you mean VBA in Ms/Access then you could write out a small batch file and then shell out to execute it.

Related

Issue with .CSV being inaccessible due to it being used by another process - VB.NET Application

We are having an issue with a .CSV file, it is being locked by another process on any shared folder location.
Before mid December this worked with no problem, but since then our guys keep getting this same error on the files. "The process cannot access the file "Filename.." because it is being used by another process" Once they are written into once and it appears that the shared file resource is keeping this file open, we have checked and we can see the close request coming through on the file server but it doesn't appear to be successfully closing said file.
Here is the code snippet which I have chopped down to get rid of the unnecessary information for our VB.Net application which creates and writes to the file in case it relates to it but it appears to be something with file sharing on Windows.
Try
Dim nowPathString As String = Now().ToString("yyyyMMdd-hhmmss")
Dim nowString As String = Now().ToString() '
Dim csvFilePath As String = $\\webserver\ExcelTest\Test-{nowPathString}.csv 'Path to create or existing file
Dim outFile As IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(csvFilePath, False)
outFile.WriteLine("Warehouse, StockItemCode, AllocationQuantity, Reference, SecondReference, ActivityDate")
outFile.WriteLine($"Main, SHE060, 1, 123456, 123456-1, {nowString}")
outFile.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Any help or suggestions on this is greatly appreciated!
We thought this issue may be server related so we created a shared folder on our local C drive and the same issue occurred but if you save the file onto your local C drive normally it works.
The way to get around this being stored on our server is to go in and manually close the file down by using console root and the "Shared Folders" snap-in.

How to send an email using VBScript without CDO

I can't send email with VBScript because the Cdo resources have been removed.
For example, this line of code does not work because when I open the link, I see that the resource has been removed:
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.your.com"
On Microsoft's site it says: "This content is no longer actively maintained."
https://learn.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2003/ms873037(v=exchg.65)
Is there any way to send an email using VBScript where the code doesn't need this kind of reference?

Start Domino service and word

I want to modify a word document from an agent in Lotus Script. Domino server starts as a service with an Administrator user count. The word document is attached in a Lotus Notes document. I extract the document in a folder that Domino has access.
When the Domino server (as service) runs the process, the Domino displays an error. But when I start the Domino server as application, the process runs well and it doesn't get any error.
The script code is the next:
Set rtItem = doc_perfil.GetFirstItem(campo)
Set obj = rtitem.EmbeddedObjects(0)
sFile = RUTA + "\" + ReplaceSubstring(nameNewFile, "/", "-") + ".docx"
Call obj.ExtractFile(sFile)
OLE_OBJECT = "word.application"
Set Word = CreateObject (OLE_OBJECT)
Set templt = Word.Documents.Add (sFile)
The line that produces the error is "Set templt = Word.Documents.Add (sFile)"
As a first point, running Word on a server is totally unsupported by Microsoft.
The quick and dirty way round this is to not run Domino as a service. A service can't interact with the UI which it needs to for OLE.
The downside to this is that the Domino Server will need to be manually restarted if the Windows server ever reboots.
The proper way to do this is to do what you need in java using a library like docx4j or Apache POI. As you don't include any code beyond opening the word doc, I can't comment further on what would be a suitable library.
In the line of code,
Set templt = Word.Documents.Add (sFile)
Add, does not take parameters, please try word.documents.open
If the Domino is not run as a service and still the error occurs, change the security level of the agent to 3 (run will full admin rights)

Running vbscript in html file

I wrote vbscript inside my html file for my site and I can't get it to work. I know it only works in internet explorer as thats the common answer I see people write with this issue. I am able to get basic vbscript working, but when trying to use filesystemobjects to open a text file nothing happens. Code being used is below.
<Script type="text/vbscript">
Dim fsobj, objtxt, thearr
Set fsobj = CreateObject("Scripting.FileSystemObject")
Set objtxt = fsobj.OpenTextFile("./subfolder/foo.txt", 1)
thearr = split(objtxt.readline, ",")
document.write(thearr(0) & " and " & thearr(1))
</script>
I get the code to work when saving with asp extension but not when I save as html, is there a way to get it to work with only using the html extension? If not does someone have an explanation as to why scripting filesystemobject without the asp extension doesn't work? I seem to can't search for the answer I'm looking for.
When you were using the FileSystemObject from an ASP page, then you were manipulating the file-system of the server. This is permitted.
However, when you use the code above, you are executing the code on the client. It is not permitted to access the clients file-system from inside Internet Explorer, as it would have serious security implications. The technical term is "sandboxing".
If you need to interact with the file-system on the client machine, you will need to use a technology such as ActiveX.
When you run the script as client script, it would try to access the file from the client computer, not the server. The file isn't there, and even if it was, your script would not be allowed to access it.
You should consider using HTML Applications by renaming your file with a .hta suffix.
An HTA executes without the constraints of the internet browser security model; in fact, it executes as a "fully trusted" application.
HTML files running inside internet browsers are considered as "untrusted" because the code comes from the internet, and is generally considered as "untrusted" as such the browser enforces a tight security model that prevents those HTML pages gaining access to your computer, which is why the FileSystemObject is unable to open the text file. However, as a HTA it is no longer being run by your browser, but via Microsoft's MSHTA application which grants your script full trust.
For more information see HTML Application - Wikipedia.

VBS file communication/execution

I have a ftp server that i have written VBS scripts for, now I need an easy way to run them from my website. So i want to open my website, enter the username, password, users name and click submit, it must then run the VBS and insert the data and the VBS will then create the user on the FTP.
What is the best way to do this? should I load the VBS stuff into a application with webservice listener and build and execute it and then my site must communicate via the webservice, or should i rather build a local asp page and host it which when posted too runs the vbs file and gives it the data. Please explain how you would go about coding it if you leave a response :D
You could use
<%
Dim oWShell
Set oWShell = Server.CreateObject("WScript.Shell")
strCommand = "cmd.exe /c cscript C:\AbsolutePath\To\Your\VBSFile.vbs"
oWShell.Run strCommand, 1, true
Set oWShell = Nothing
%>
WShell and WShell.Run requires elevated access permissions on the web server. Make sure that the authenticated user (or IUsr) has those permissions.

Resources