Switching from file share to HTTP
Greetings !
Programming is my weak spot but that doesnt stop me from trying to ease up my work. I have found code on internet that retrieves data in formfields in Word documents that are in directory. This is code:
Sub PoberiPodatke()
Dim oPath As String
Dim FileArray() As String
Dim oFileName As String
Dim i As Long
'Requires reference to MS ActiveX Data Objects 2.8 Library
Dim vConnection As New ADODB.Connection
Dim vRecordSet As New ADODB.Recordset
Dim myDoc As Word.Document
'Call a Function to identify the common batch folder
oPath = GetPathToUse
If oPath = "" Then
MsgBox "A folder was not selected"
Exit Sub
End If
'Identify the files names
oFileName = Dir$(oPath & "*.doc")
ReDim FileArray(1 To 1000) 'A number larger the expected number of replies
When I try to apply this same code (macro) in HTTP enviroment through SharePoint Portal server it doesnt work.
Problem probably lies in bolded and underlined part.
Can someone help ? With what can I swap bolded line to be able to get Word data?
I would be very gratefull and thankfull !!!
Kepezzo
Re: Switching from file share to HTTP
What exacrtly are you trying to do? Open a Word document on a server and send the contents back as html?
Re: Switching from file share to HTTP
On this portal there ara directories with Word files all made with same template. I would like to get data from these Word files into Access database for further managing of these data. So only retrieving data. Now this works fine on file server and PC, but I cant run this macro to get data from files that are on SharePoint Portal Server.
I hope I am not complocating too much. :sick:
Re: Switching from file share to HTTP
You want to trigger a macro on a server to run on Word documents on the server, putting data from those documents into a database on the server - but you want to do it from a remote client?
Look into CGI. Connect to the server, calling a cgi app that will run whatever you want on the server. You don't need anything more on the client than a web browser.
Re: Switching from file share to HTTP
I would like to run macro on a server in Access database, retrieving data from Word documents, that are on SharePoint Portal Server (SPS).
I am appending whole macro that works fine on file server or PC, but it doesnt work when approaching SPS. Can you tell me what to change in this macro tu run properly ?
MANY THANKS !
Sub TallyData()
Dim oPath As String
Dim FileArray() As String
Dim oFileName As String
Dim i As Long
'Requires reference to MS ActiveX Data Objects 2.8 Library
Dim vConnection As New ADODB.Connection
Dim vRecordSet As New ADODB.Recordset
Dim myDoc As Word.Document
'Call a Function to identify the common batch folder
oPath = GetPathToUse
If oPath = "" Then
MsgBox "A folder was not selected"
Exit Sub
End If
'Identify the files names
oFileName = Dir$(oPath & "*.doc")
ReDim FileArray(1 To 1000) 'A number larger the expected number of replies
'Add file name to the array
Do While oFileName <> ""
i = i + 1
FileArray(i) = oFileName
'Get the next file name
oFileName = Dir$
Loop
'Resize and preserve the array
ReDim Preserve FileArray(1 To i)
Application.ScreenUpdating = False
'Provide connection string for data using Jet Provider for Access database
vConnection.ConnectionString = "data source=\\server_with_Access_database\datafromword.mdb;" & _
"Provider=Microsoft.Jet.OLEDB.4.0;"
vConnection.Open
vRecordSet.Open "MyTable", vConnection, adOpenKeyset, adLockOptimistic
'Clear any existing records in database
vConnection.Execute "DELETE * FROM MyTable"
'Open each file and extract data
For i = 1 To UBound(FileArray)
Set myDoc = Documents.Open(FileName:=oPath & FileArray(i), Visible:=False)
vRecordSet.AddNew
With myDoc
If .FormFields("Naslov").Result <> "" Then _
vRecordSet!Name = .FormFields("Naslov").Result
If .FormFields("Datum").Result <> "" Then _
vRecordSet("Datum analize") = .FormFields("Datum").Result
If .FormFields("Text3").Result <> "" Then _
vRecordSet("Favorite Color") = .FormFields("Text3").Result
.Close
End With
Next i
vRecordSet.Update
vRecordSet.Close
vConnection.Close
Set vRecordSet = Nothing
Set vConnection = Nothing
Application.ScreenUpdating = True
End Sub
Private Function GetPathToUse() As Variant
'Get the folder containing the files
'Note uses the "Copy Dialog" which enables the "open" option
With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
GetPathToUse = .Directory
Else
GetPathToUse = ""
Exit Function
End If
End With
If Left(GetPathToUse, 1) = Chr(34) Then
GetPathToUse = Mid(GetPathToUse, 2, Len(GetPathToUse) - 2)
End If
End Function
Re: Switching from file share to HTTP
Quote:
Originally Posted by kepezzo
I would like to run macro on a server in Access database
You can't run Access as a CGI app.
Quote:
Can you tell me what to change in this macro tu run properly ?
Change the idea that you can use http to run Access remotely. Maybe run a VNC server on the server and connect to it using a VNC client. Or write some remote access program that would perform the same function.