VBA coding for Sharepoint

%3CLINGO-SUB%20id%3D%22lingo-sub-2556319%22%20slang%3D%22en-US%22%3EVBA%20coding%20for%20Sharepoint%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2556319%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20recently%20moved%20all%20of%20our%20drives%20to%20Sharepoint.%26nbsp%3B%20The%20problem%20that%20we%20are%20having%20is%20the%20file%20paths%20that%20were%20set%20up%20for%20our%20macros%20no%20longer%20works%20as%20they%20are%20directing%20to%20the%20drive%20and%20not%20sharepoint.%26nbsp%3B%20I%20have%20attempted%20to%20update%20these%20but%20having%20issues%20with%20the%20path%2Flocation.%26nbsp%3B%20This%20macro%20is%20pulling%20a%20txt%20file%20and%20exporting%20the%20data%20into%20excel.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20help!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20the%20current%20macro%20with%20the%20old%20file%20path%20(text%20in%20red)%3A%3C%2FP%3E%3CP%3ESub%20Import_All_Text_Files_2007()%3CBR%20%2F%3E%3CBR%20%2F%3EDim%20nxt_row%20As%20Long%3CBR%20%2F%3E%3CBR%20%2F%3E'Change%20Path%3CBR%20%2F%3EConst%20strPath%20As%20String%20%3D%20%3CFONT%20color%3D%22%23FF0000%22%3E%22S%3A%5CVMA%5CWEX%20TRANSACTIONS%5CWEX%20DQRY%20Data%5CNEW%20BULKS-CURRENT%20WEEK%5C%22%3C%2FFONT%3E%3CBR%20%2F%3EDim%20strExtension%20As%20String%3CBR%20%2F%3E%3CBR%20%2F%3E'Stop%20Screen%20Flickering%3CBR%20%2F%3EApplication.ScreenUpdating%20%3D%20False%3CBR%20%2F%3E%3CBR%20%2F%3EChDir%20strPath%3CBR%20%2F%3E%3CBR%20%2F%3E'Change%20extension%3CBR%20%2F%3EstrExtension%20%3D%20Dir(strPath%20%26amp%3B%20%22*.txt%22)%3CBR%20%2F%3E%3CBR%20%2F%3EDo%20While%20strExtension%20%26lt%3B%26gt%3B%20%22%22%3CBR%20%2F%3E%3CBR%20%2F%3E'Adds%20File%20Name%20as%20title%20on%20next%20row%3CBR%20%2F%3ERange(%22A65536%22).End(xlUp).Offset(1%2C%200).Value%20%3D%20strExtension%3CBR%20%2F%3E%3CBR%20%2F%3E'Sets%20Row%20Number%20for%20Data%20to%20Begin%3CBR%20%2F%3Enxt_row%20%3D%20Range(%22A65536%22).End(xlUp).Offset(1%2C%200).Row%3CBR%20%2F%3E%3CBR%20%2F%3E'Below%20is%20from%20a%20recorded%20macro%20importing%20a%20text%20file%3CBR%20%2F%3EWith%20ActiveSheet.QueryTables.Add(Connection%3A%3D%20_%3CBR%20%2F%3E%22TEXT%3B%22%20%26amp%3B%20strPath%20%26amp%3B%20strExtension%2C%20Destination%3A%3DRange(%22%24A%24%22%20%26amp%3B%20nxt_row))%3CBR%20%2F%3E.Name%20%3D%20strExtension%3CBR%20%2F%3E.FieldNames%20%3D%20True%3CBR%20%2F%3E.RowNumbers%20%3D%20False%3CBR%20%2F%3E.FillAdjacentFormulas%20%3D%20False%3CBR%20%2F%3E.PreserveFormatting%20%3D%20True%3CBR%20%2F%3E.RefreshOnFileOpen%20%3D%20False%3CBR%20%2F%3E.RefreshStyle%20%3D%20xlInsertDeleteCells%3CBR%20%2F%3E.SavePassword%20%3D%20False%3CBR%20%2F%3E.SaveData%20%3D%20True%3CBR%20%2F%3E.AdjustColumnWidth%20%3D%20True%3CBR%20%2F%3E.RefreshPeriod%20%3D%200%3CBR%20%2F%3E.TextFilePromptOnRefresh%20%3D%20False%3CBR%20%2F%3E.TextFilePlatform%20%3D%20850%3CBR%20%2F%3E.TextFileStartRow%20%3D%201%3CBR%20%2F%3E.TextFileParseType%20%3D%20xlDelimited%3CBR%20%2F%3E.TextFileTextQualifier%20%3D%20xlTextQualifierDoubleQuote%3CBR%20%2F%3E'Delimiter%20Settings%3A%3CBR%20%2F%3E.TextFileConsecutiveDelimiter%20%3D%20True%3CBR%20%2F%3E.TextFileTabDelimiter%20%3D%20True%3CBR%20%2F%3E.TextFileSemicolonDelimiter%20%3D%20False%3CBR%20%2F%3E.TextFileCommaDelimiter%20%3D%20False%3CBR%20%2F%3E.TextFileSpaceDelimiter%20%3D%20False%3CBR%20%2F%3E%3CBR%20%2F%3E.TextFileTrailingMinusNumbers%20%3D%20False%3CBR%20%2F%3E.Refresh%20BackgroundQuery%3A%3DFalse%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3E%3CBR%20%2F%3EstrExtension%20%3D%20Dir%3CBR%20%2F%3ELoop%3CBR%20%2F%3E%3CBR%20%2F%3EApplication.ScreenUpdating%20%3D%20True%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2556319%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2556380%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20coding%20for%20Sharepoint%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2556380%22%20slang%3D%22en-US%22%3EI%20did%20attempt%20to%20update%20the%20path%20with%20the%20one%20drive%20location%20but%20still%20not%20working%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2751624%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20coding%20for%20Sharepoint%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2751624%22%20slang%3D%22en-US%22%3EHey%2C%20have%20you%20found%20a%20solution%20to%20this%3F%20sitting%20with%20the%20same%20issue%3C%2FLINGO-BODY%3E
New Contributor

We recently moved all of our drives to Sharepoint.  The problem that we are having is the file paths that were set up for our macros no longer works as they are directing to the drive and not sharepoint.  I have attempted to update these but having issues with the path/location.  This macro is pulling a txt file and exporting the data into excel.

 

Please help!!

 

Here is the current macro with the old file path (text in red):

Sub Import_All_Text_Files_2007()

Dim nxt_row As Long

'Change Path
Const strPath As String = "S:\VMA\WEX TRANSACTIONS\WEX DQRY Data\NEW BULKS-CURRENT WEEK\"
Dim strExtension As String

'Stop Screen Flickering
Application.ScreenUpdating = False

ChDir strPath

'Change extension
strExtension = Dir(strPath & "*.txt")

Do While strExtension <> ""

'Adds File Name as title on next row
Range("A65536").End(xlUp).Offset(1, 0).Value = strExtension

'Sets Row Number for Data to Begin
nxt_row = Range("A65536").End(xlUp).Offset(1, 0).Row

'Below is from a recorded macro importing a text file
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & strPath & strExtension, Destination:=Range("$A$" & nxt_row))
.Name = strExtension
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
'Delimiter Settings:
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False

.TextFileTrailingMinusNumbers = False
.Refresh BackgroundQuery:=False
End With

strExtension = Dir
Loop

Application.ScreenUpdating = True

End Sub

 

3 Replies
I did attempt to update the path with the one drive location but still not working
Hey, have you found a solution to this? sitting with the same issue

@Amber_Element 

Since the code doesn't work, I would guess it has nothing to do with SharePoint.
The local path is wrong. Either just a typo or the path is too long (approx. 250 characters).
Don't you have to have a double backslash in front of it? ... https?

 

Get the content of a sharepoint folder with Excel VBA

Find more infos in this Link

 

I would be happy to know if I could help.

 

NikolinoDE

I know I don't know anything (Socrates)