title: Upload document to SharePoint via VBA
body: <p>I have this code to upload a document to SharePoint via VBA by mapping it to a drive.</p>
  
  <p>I get</p>
  
  <blockquote>
    <p>"Compile error, Sub or function not defined".</p>
  </blockquote>
  
  <p>Then it highlights the second quote mark from this line:</p>
  
  <pre><code>objNet.MapNetworkDrive “A: ” , SharepointAddress
  </code></pre>
  
  <p>Below is the entire subroutine.</p>
  
  <pre><code>Sub UploadToSharepoint()
  
  Dim SharepointAddress As String
  Dim LocalAddress As String
  Dim objNet As Object
  Dim FS As Object
  SharepointAddress = "http://share.deere.com/teams/sm_at_sd/suppcaptracking/Test"
  LocalAddress = ”c: MyWorkFiletoCopy.xlsx”
  Set objNet = CreateObject(“WScript.Network”)
  Set FS = CreateObject(“Scripting.FileSystemObject”)
  objNet.MapNetworkDrive “A: ” , SharepointAddress
  
  If FS.FileExists(LocalAddress) Then
      FS.CopyFile LocalAddress, SharepointAddress
  End If
  
  objNet.RemoveNetworkDrive “A: ”
  Set objNet = Nothing
  Set FS = Nothing
  
  End Sub
  </code></pre>