N
Neil
Anyone familiar with VB.Net? I have some code I need to convert from
VB.net to VB or VBA (I will be using it in Access 2010). The code is to
upload a document to a SharePoint library (using the SharePoint
Foundation 2010 Managed COM). The original code was in C#. I used a C#
to VB.Net converter to get it into VB.Net. Now I need to get it into VB
or VBA. Is it possible?
Here is the original C# code (from
http://msdn.microsoft.com/en-us/library/ee956524.aspx):
using System;
using System.IO;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using Microsoft.SharePoint.Client;
// The following directive avoids ambiguity between the
// System.IO.File class and Microsoft.SharePoint.Client.File class.
using ClientOM = Microsoft.SharePoint.Client;
class Program
{
static void Main(string[] args)
{
ClientContext clientContext =
new ClientContext("http://intranet.contoso.com");
using (FileStream fileStream =
new FileStream("NewDocument.docx", FileMode.Open))
ClientOM.File.SaveBinaryDirect(clientContext,
"/Shared Documents/NewDocument.docx", fileStream, true);
}
}
And here is the code after it was converted to VB.Net:
Imports System.IO
Imports DocumentFormat.OpenXml.Packaging
Imports DocumentFormat.OpenXml.Wordprocessing
Imports Microsoft.SharePoint.Client
' The following directive avoids ambiguity between the
' System.IO.File class and Microsoft.SharePoint.Client.File class.
Imports ClientOM = Microsoft.SharePoint.Client
Class Program
Private Shared Sub Main(args As String())
Dim clientContext As New ClientContext("http://intranet.contoso.com")
Using fileStream As New FileStream("NewDocument.docx", FileMode.Open)
ClientOM.File.SaveBinaryDirect(clientContext, "/Shared
Documents/NewDocument.docx", fileStream, True)
End Using
End Sub
End Class
Any idea how this would look in VB or VBA?
Thanks!
Neil
VB.net to VB or VBA (I will be using it in Access 2010). The code is to
upload a document to a SharePoint library (using the SharePoint
Foundation 2010 Managed COM). The original code was in C#. I used a C#
to VB.Net converter to get it into VB.Net. Now I need to get it into VB
or VBA. Is it possible?
Here is the original C# code (from
http://msdn.microsoft.com/en-us/library/ee956524.aspx):
using System;
using System.IO;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using Microsoft.SharePoint.Client;
// The following directive avoids ambiguity between the
// System.IO.File class and Microsoft.SharePoint.Client.File class.
using ClientOM = Microsoft.SharePoint.Client;
class Program
{
static void Main(string[] args)
{
ClientContext clientContext =
new ClientContext("http://intranet.contoso.com");
using (FileStream fileStream =
new FileStream("NewDocument.docx", FileMode.Open))
ClientOM.File.SaveBinaryDirect(clientContext,
"/Shared Documents/NewDocument.docx", fileStream, true);
}
}
And here is the code after it was converted to VB.Net:
Imports System.IO
Imports DocumentFormat.OpenXml.Packaging
Imports DocumentFormat.OpenXml.Wordprocessing
Imports Microsoft.SharePoint.Client
' The following directive avoids ambiguity between the
' System.IO.File class and Microsoft.SharePoint.Client.File class.
Imports ClientOM = Microsoft.SharePoint.Client
Class Program
Private Shared Sub Main(args As String())
Dim clientContext As New ClientContext("http://intranet.contoso.com")
Using fileStream As New FileStream("NewDocument.docx", FileMode.Open)
ClientOM.File.SaveBinaryDirect(clientContext, "/Shared
Documents/NewDocument.docx", fileStream, True)
End Using
End Sub
End Class
Any idea how this would look in VB or VBA?
Thanks!
Neil