Get particular item count in sharepoint list using designer Workflow
How to get specific item count in sharepoint list using designer Workflow 2013.
For Example
Title Count
x 1
y 1
x 2
x 3
HI Thiru,
Can you please elaborate your problem. Is that Title and count are your list columns you want to fetch the value of count column based on title?
If my interpretation in not wrong, then it's not possible in SPD with the case you have mentioned in your question as Title='x' is having 3 different entries and SPD activity will always return first matching item and ignore the rest with warning message.
Regards,
Brij K
Similar Messages
-
Split a text based on delimiter and add items to a sharepoint list using SPD workflow
Hi All
I have to store repeating table data into a sharepoint list. I have developed an approach to store data into a sharepoint list using web services as mentioned at
http://www.bizsupportonline.net/infopath2007/how-to-submit-items-rows-repeating-table-infopath-sharepoint-list.htm. However this approach is working when form opened client only but when I opened it in browser this approach is giving error. Now I'm looking
to promote repeating table data by combining items will a delimiter semi-colon (;). Please let me know how can I split the promoted field value using de-limiter and add it to a sharepoint list.
Note:
I'm working on SharePoint online 2010. (I don't have sharepoint on-premise, so I can't use SharePoint Object Model)
If anybody know how to deal with this, please let me know.
Thank you in advance.Hi Chuchendra,
According to your description, my understanding is that you want to split the promoted field value in InfoPath form which was combined using semi-colon and add it to a SharePoint list.
I recommend to submit the data to another SharePoint list first(use a column to store the value) and then create calculated columns to user formula to split the value, then use workflow to update the list where you want to add the value with the divided
values.
For example: the value is aa;bb;cc;dd.
Based on the number of the semi-colons, we need to create one column to store the original value(named test for example), four calculated columns(v1,v2,v3,v4) to store the divided values and two more calculated columns(flag1,flag2) for use in the formula.
v1: =LEFT([test],FIND(";",[test])-1)
flag1: =RIGHT([test],LEN([test])-FIND(";",[test]))
v2: =LEFT([flag1],FIND(";",[flag1])-1)
flag2: =RIGHT([flag1],LEN([flag1])-FIND(";",[flag1]))
v3: =LEFT([flag2],FIND(";",[flag2])-1)
v4: =RIGHT([flag2],LEN([flag2])-FIND(";",[flag2]))
We can also use Client Object Model to write code to split the value of the field.
You can download the dll files form the link below:
http://www.microsoft.com/en-in/download/details.aspx?id=21786
Best regards.
Thanks
Victoria Xia
TechNet Community Support -
How to update an existing item in a sharepoint list using the WSS adapter for Biztalk
Is there a way that a record in SP list be updated using WSS adapter in biztalk ?
BizTalk 2013 and SP 2013 ..
Regards
Ritu Raj
When you see answers and helpful posts,
please click Vote As Helpful, Propose As Answer, and/or Mark As AnswerA ListItem has its own unique row id so in all likelihood, an insert with the same data will result in a new list entry. The Lists Web Service however, has an UpdateListItem method which will take an update request. [refer
http://msdn.microsoft.com/en-us/library/office/websvclists.lists.updatelistitems(v=office.15).aspx ]
There is another note in the conference (marked answered) to your List Item Update problem. Probably worth a try too. [refer
http://social.msdn.microsoft.com/Forums/en-US/bee8f6c6-3259-4764-bafa-6689f5fd6ec9/how-to-update-an-existing-item-in-a-sharepoint-list-using-the-wss-adapter-for-biztalk?forum=biztalkgeneral ]
Regards. -
Add/update an item to an external list using Designer WF
Hi,
I have two lists (A & B). A- regular SharePoint list, B- External list.
Now, I have a Designer WF on A to add/update the items to the B. Unfortunately, SP 2013 killed the feature to update the external list directly using Designer WF 2013. However, I was able to use REST services to add/update item to the external list from
the browser either using Fiddler or Mozilla client side tools.So I thought I could use Designer HTTP call action to achieve this. But when I tried to use the HTTP call from the Designer WF, it won't add/update the items to B. I thought I was doing some
kind of mistake while doing that HTTP call, so I tried replacing the list guid to some other regular list and it works. Its not working for an external list but working for any regular list.
I'm not sure why I could not do that using the Designer while I can do it from browser. Can someone please help me out?
Thanks!
Thanks, HitchsHi Jeroen,
Use following funtion call with mentioned parameters
call function 'CRM_ORDER_MAINTAIN'
exporting
it_status = lt_status1
changing
ct_input_fields = lt_input_fields
exceptions
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
others = 5.
here in for parameter lt_status1 u can fill up your required status and then execute the FM.
After that execute FM BAPI_TRANSACTION_COMMIT.
Best Regards,
Pratik Patel
<b>Reward with Points!</b> -
Check if user belongs to specific sharepoint group using designer workflow
Hi,
I am developing a SharePoint 2010 Designer workflow [Reusable workflow].
Can I check if the workflow initiator belongs to specific SharePoint group. Do we have any action/activity for this?
I have some business logic that needs to be executed if user initiating the workflow belongs to specific SharePoint group.
Any suggestions/pointers on this would be highly appreciated.
Regards, Ketan GandhiHi,
You will not able to see it OOTB. You can refer this link if you want this
workflow action.
http://spdactivities.codeplex.com.
Thanks.Please mark it as an answer if it helped. -
HTML + JQuery (CSOM) to add multiple item to a Sharepoint list and get their IDs
Hi everyone.
I try to use HTML + JQuery in CEWP to build some sort of analog of InfoPath's repeating table in order to be able to insert multiple items in a Sharepoint list using CSOM.
The current task is to get the IDs of inserted items (in order to use those IDs later to add attachments to the list items) as soon as they are added to the list. I've tried several ways but couldn't get the IDs of all inserted items. Usually
I get "-1" as an ID for every item except the last one, which returns me the correct ID.
Bellow is the code.
<script src="/testsite1/SiteAssets/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="/testsite1/SiteAssets/jquery.SPServices.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
var click = 1;
$("#btn_id_1").click(function() {
click ++;
$("#tr_id_1").clone().appendTo("#tbl_id_1").attr("id", "tr_id_" + click.toString()).find("input").val("");
$("#btn_id_2").click(function() {
Save();
function Save() {
var ctx = new SP.ClientContext.get_current();
var taskList = ctx.get_web().get_lists().getByTitle('Tasks');
var taskItemInfo = new SP.ListItemCreationInformation();
var vendor;
var certname;
var certid;
$("#tbl_id_1 tr").each(function() {
vendor = ($(this).find(".vendor")).val();
certname = ($(this).find(".certname")).val();
certid = ($(this).find(".certid")).val();
newTask = taskList.addItem(taskItemInfo);
newTask.set_item('Title', vendor);
newTask.set_item('Request_', certname);
newTask.set_item('h', certid);
newTask.update();
ctx.load(newTask);
ctx.executeQueryAsync(addTaskSuccess, addTaskFailure);
//timeout();
function timeout() {
alert ("!!!");
function addTaskSuccess(sender, args) {
alert(newTask.get_id());
//AddAttachment(newTask.get_id())
function addTaskFailure(sender, args) {
//alert(newTask.get_id());
alert("no");
window.location = window.location.pathname;
</script>
<div id="div_id_1" class="div_class_1">
<table id="tbl_id_1">
<tbody>
<tr id="tr_id_1">
<td>Vendor:<br><input type="text" class="vendor" /></td>
<td>Cert. Name:<br><input type="text" class="certname" /></td>
<td>Cert. ID:<br><input type="text" class="certid" /></td>
<td>Attachment:<br><input type="file" class="attachment" /></td>
</tr>
</tbody>
</table>
<div><button id="btn_id_1" type="button" width="10" height="10">+</button></div>
<div><button id="btn_id_2" type="button">Save</button></div>
</div>Here's a working solution (thanks to
this guy)
<script src="/testsite1/SiteAssets/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="/testsite1/SiteAssets/jquery.SPServices.min.js" type="text/javascript"></script>
<script type="text/javascript">
var array = [];
$(document).ready(function() {
var click = 1;
$("#btn_id_1").click(function() {
click ++;
$("#tr_id_1").clone().appendTo("#tbl_id_1").attr("id", "tr_id_" + click.toString()).find("input").val("");
$("#btn_id_2").click(function() {
//Save();
//Call();
var asyncPromises = Save();
asyncPromises.done(function(result) {
//alert(array.length);
console.log(array.length);
for (var i=0; i<array.length; i++) {
//alert(array[i].get_id());
console.log(array[i].get_id());
asyncPromises.fail(function(result) {
function Save() {
var buildDeferredSaves = $.Deferred(function() {
//var array = [];
var ctx = new SP.ClientContext.get_current();
var taskList = ctx.get_web().get_lists().getByTitle('Tasks');
var taskItemInfo;
var vendor;
var certname;
var certid;
$("#tbl_id_1 tr").each(function() {
vendor = ($(this).find(".vendor")).val();
certname = ($(this).find(".certname")).val();
certid = ($(this).find(".certid")).val();
taskItemInfo = new SP.ListItemCreationInformation();
newTask = taskList.addItem(taskItemInfo);
newTask.set_item('Title', vendor);
newTask.set_item('Request_', certname);
newTask.set_item('h', certid);
newTask.update();
ctx.load(newTask);
array.push(newTask);
ctx.executeQueryAsync(
function() {
// Successful
buildDeferredSaves.resolve();
function(sender, args) {
// Failure
buildDeferredSaves.reject(args.get_message());
return buildDeferredSaves.promise();
</script>
<div id="div_id_1" class="div_class_1">
<table id="tbl_id_1">
<tbody>
<tr id="tr_id_1">
<td>Vendor:<br><input type="text" class="vendor" /></td>
<td>Cert. Name:<br><input type="text" class="certname" /></td>
<td>Cert. ID:<br><input type="text" class="certid" /></td>
<td>Attachment:<br><input type="file" class="attachment" /></td>
</tr>
</tbody>
</table>
<div><button id="btn_id_1" type="button" width="10" height="10">+</button></div>
<div><button id="btn_id_2" type="button">Save</button></div>
</div> -
SharePoint 2013 Rest API - How to get the item count with startsWith
Hi All,
I am using the below url to get the item count for specfied startsWith. For example I want to know how many items are there in the list which starts with "A". When i hit the below url in the address bar i am getting HTTP not found.
siteURL/sites/Apps/SharePointApp3/_vti_bin/listdata.svc/SampleList/items?$filter=startsWith(Title,’A’)
Navaneethwhat
is SharePointApp3.
here.
it is a webpart.
this will not work on webpart\apps
Also I am not sure if it will work with specific SampleList
Try
siteURL/sites/Apps/SharePointApp3/SampleList/_vti_bin/listdata.svc/Keywords?$filter=substringof('r',Title)
If this helped you resolve your issue, please mark it Answered -
SSRS reporting with sharepoint list using Distinct and Multivalue parameters
i want create ssrs report with sharepoint list using ms-vs(2008). i want create Distinct multivalue parameters by using CAML query. There is any way we put CAML query where we use Distinct keyword and IN clause in CAML query... i hope all experts will
understand my poor English... sorry for poor English.. plz help meHi AsifMehmood,
Per my understanding you have create an SSRS report with SharePoint list, now you don’t know to create the distinct parameters by using CAML query, right?
For the CAML language doesn’t have any reserved word (or tag) to set this particular filter to remove duplicate results, but we can use the custom code to do this function. I have tested on my local environment and we can do that by create one hidden parameter(Param1)
to get all the values from the fields which will add the filter and then create another parameter(Param2) to get the distinct values based on the Param1, we use the custom code to do the deduplication.
Step by Steps information in below thread for your reference to create the parameters and the custom code:
"How to get distinct values of sharepoint column using SSRS"
Other similar thread for your reference:
https://audministrator.wordpress.com/2014/02/17/sharepoint-list-add-distinct-parameter-value/
If your problem still exists, please feel free to ask and also try to provide us more details information.
Regards
Vicky Liu -
How do I query a SharePoint List using a url and filtering on date?
I am reading a SharePoint list using jquery. Everything is working fine
except for the filter. Each list item has an expiration date. I want to retrieve JUST the items that have not expired (Expires > Today) but I can't figure out the url syntax and I've been searching all day for an example and
can't find one. Could someone please help?!? See bold code below.
Thanks,
Glen
$(document).ready(function ()
<strong>var qryWCFUrl = "/sites/MMTP1/_vti_bin/listdata.svc/MMAlerts?$filter=(Expires gt '08/10/2011')&$orderby=Title";
</strong> $.getJSON(qryWCFUrl, function (results)
$.each(results.d.results, function (i, mmAlert)
itemID = mmAlert.Id;
mmTitle = mmAlert.Title;
mmClass = mmAlert.ClassValue;
//alert("Item="+itemID+" Title="+mmTitle+" Class="+mmClass);
AddMMStatus(mmAlert.Id,mmAlert.Title,mmAlert.ClassValue);Fadi,
Thanks for your response. I actually have another version of the code that uses the SP client objects that works. The problem is site boundries. Let me give a more complete project explanation.
I am creating a master page for a new intranet. As part of this master page, I want to read from an SP list of alerts and post each alert (if not expired) in the SP status bar. I've gotten this to work with SP client objects and jquery (except
for the date filter part). Both of these solutions work fine on the top site level. BUT when trying it out at the sub-site level, the SP client objects version of my code fails. The jQuery version works except the date filtering.
I looked at the example from your link and it looks like a bit of a hybrid to my approaches: JQuery with CAML. My question is; does this example permit me to access a list in the top-level site from the subsites? Please excuse my ignorance,
but I am an EXTREME newbie in this having spent the past 8 years as a VB.Net developer and a little bit of ASP.Net.
Below are the two different versions of my code in different versions of my master page definition:
SP Client Object Version
<script type="text/javascript">
// <![CDATA[
ExecuteOrDelayUntilScriptLoaded(LoadAlerts, "sp.js");
var ctx;
var currAlerts;
function LoadAlerts() {
ctx = new SP.ClientContext.get_current();
list = ctx.get_web().get_lists('/sites/MMTP1/Lists/').getByTitle('MMAlerts');
var cmlQry = new SP.CamlQuery();
var camlExp = '<query><Query><Where><Gt><FieldRef Name="Expires" /><Value IncludeTimeValue="FALSE" Type="DateTime"><Today /></Value></Gt></Where></Query></query>';
cmlQry.set_viewXml(camlExp);
currAlerts = list.getItems(cmlQry);
ctx.load(currAlerts,'Include(ID,Title,Class)');
ctx.executeQueryAsync(GetAlertsSuccess,GetAlertsFailed);
function GetAlertsSuccess() {
var lstEnum = currAlerts.getEnumerator();
while(lstEnum.moveNext()) {
var mmAlert = lstEnum.get_current();
AddMMStatus(mmAlert.get_item('ID'),mmAlert.get_item('Title'),mmAlert.get_item('Class'));
function GetAlertsFailed(sender,args) {
alert('Alerts load failed: ' + args.tostring);
function AddMMStatus(msgID, strTitle, strClass) {
var statID;
var statClass;
var statTitle;
statClass = "<a href=\"#\" onclick=\"javascript:DisplayAlert("+msgID+");\">" + strClass + ": </a>";
statTitle = "<a href=\"#\" onclick=\"javascript:DisplayAlert("+msgID+");\">" + strTitle + "</a>";
statID = SP.UI.Status.addStatus(statClass, statTitle, true);
SP.UI.Status.setStatusPriColor(statID,"red");
function DisplayAlert(msgID) {
var options = {
title: "Miller & Martin Alert!",
url: "/sites/MMTP1/SitePages/ShowAlert02.aspx?ID="+msgID,
allowMaximize: false,
showClose: true
SP.UI.ModalDialog.showModalDialog(options);
// ]]>
</script>
JQuery Version (works except for filtering by date)
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" >
// <![CDATA[
var itemID;
var mmTitle;
var mmClass;
$(document).ready(function ()
var qryWCFUrl = "/sites/MMTP1/_vti_bin/listdata.svc/MMAlerts?$filter=(Expires gt '08/10/2011')&$orderby=Title";
$.getJSON(qryWCFUrl, function (results)
$.each(results.d.results, function (i, mmAlert)
itemID = mmAlert.Id;
mmTitle = mmAlert.Title;
mmClass = mmAlert.ClassValue;
AddMMStatus(mmAlert.Id,mmAlert.Title,mmAlert.ClassValue);
function AddMMStatus(msgID, strTitle, strClass, strSeverity) {
var statID;
var statClass;
var statTitle;
statClass = "<div id=\"mmAlertTitle\" style=\"display:inline-block;\"><a href=\"#\" onclick=\"javascript:DisplayAlert("+msgID+");\">" + strClass + ": </a></div>";
statTitle = "<div id=\"mmAlertDetail\" style=\"display:inline-block;\"><a href=\"#\" onclick=\"javascript:DisplayAlert("+msgID+");\">" + strTitle + "</a></div>";
statID = SP.UI.Status.addStatus(statClass, statTitle, true);
SP.UI.Status.setStatusPriColor(statID,"green");
function DisplayAlert(msgID) {
var options = {
title: "Miller & Martin Alert!",
url: "/sites/MMTP1/SitePages/ShowAlert02.aspx?ID="+msgID,
allowMaximize: false,
showClose: true
SP.UI.ModalDialog.showModalDialog(options);
// ]]>
</script> -
Check duplicate items in two sharepoint lists
Hi, I have 2 separate sharepoint lists, both contrain user names. e.g: Jan Jaap.
I want sharepoint to automaticly compare those lists to see if there is any name in both lists and notify me about it. For example :
List 1: Firstname | Surname
Jan - Jaap
Steen - Vos
george - bush
List 2: Firstname | Surname
Jan - Jaap
fox - washington
brian - potter
both lists contain jan jaap. and i want sharepoint to notice that and send me and email about it :p.
Is this in any way possible?
Thanks in advance!!You can use below tool
http://www.metalogix.com/help/Content%20Matrix%20Console/SharePoint%20Edition/002_HowTo/004_SharePointActions/003_CompareSitesAndLists.htm
Or if you want to do it programmatic try below:
http://sharepoint.stackexchange.com/questions/60917/compare-items-of-two-sharepoint-lists
SPWeb web = SPContext.Current.Web;
SPList list = web.Lists["Employee"];
string query = @"<Where>
<Eq>
<FieldRef Name='Position' /><Value Type='Choice'>{0}</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name='Salary' Ascending='False' />
</OrderBy>";
query = string.Format(query, "Developer");
SPQuery spQuery = new SPQuery();
spQuery.Query = query;
SPListItemCollection items = list.GetItems(spQuery);
If this helped you resolve your issue, please mark it Answered -
Help with Joining two SharePoint lists using LINQ
Hi Guys,
I have found many threads with this question. Although I had one doubt. I wanted to know that while performing a Join operation on two SharePoint Lists using LINQ does the column on which we are performing the join operation need to be a Lookup column?
I was initially using CAML but since my lists does not contain lookup columns I switched to LINQ but my doubt still remains.
I would really appreciate any help from you guys and also would appreciate if I could get some examples that I could refer to.
Thank youJoins in LINQ to SharePoint 2010
How to: Query Using LINQ to SharePoint
This post is my own opinion and does not necessarily reflect the opinion or view of Slalom. -
How to Enable Ratings on SharePoint List using Client Object Model code for Office 365 SharePoint Site.
Thanks in Advance
Rajendra KHi Rajendra,
here you are the code and the blog, let me know if this helps
using (ClientContext ctx = new ClientContext(https://yourSiteUrl))
Web w = ctx.Web;
List l = w.Lists.GetByTitle("yourListName");
ctx.Load(l, info => info.Id);
ctx.ExecuteQuery();
string ListID = l.Id.ToString();
Microsoft.Office.Server.ReputationModel.Reputation.SetRating(ctx, ListID, 1, 5);
ctx.ExecuteQuery();
http://blogs.technet.com/b/speschka/archive/2013/07/08/how-to-use-csom-with-ratings-in-sharepoint-2013.aspx
Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation -
Is there a means to get an item count within folders in Yosemite?
Is there a means to get an item count within folders in Yosemite?
Yes.
Turn on 'Show Status bar' -
Using Powershell cmdlet i get all the details..But i want to get these Details by using EWS Managed Api.Is It Possible to do???
Powershell Cmdlet,
Get-MailboxStatistics -Identity Username, Using this cmdlets all the details will get displayed.
DeletedItemCount:5 //Here how this count comes.In My OutlookWebApp the deleteditems folder contains 13 items in it..But the count shows only 5.
TotalDeletedItemSize:5.465 Kb//Even this value too does not match with DeletedItems Folder size in owa.
AssociatedItemCount:12
LastLogOnTime:11/11/11 12:43PM
LastLogOff Time:11/11/11 2:43PM
In EWS,
By Looping through all folders i can get the total item count and total item size.Even i can get deleteditems count .But that value does not match With the powershell value.Even the TotalDeletedItemSize
Doesnt match.
Using EWS Managed Api ,Looping through folders i can get ItemCount,TotalitemSize,(DeletedItems,TotalDeleteditemSize(These TwoValues Does not match with values comes from powershell))
Now how to get the Associated item count and lastlogoff and logon time using EWS managed Api.Is it Possible???
And even y the deleteditems count and size values varies between EWS and powershell.What happens if you execute the below code?
Get-MailboxFolderStatistics [email protected] | where {$_.FolderPath -like "/Deleted Items"}
Refer this blog. You may get some dice
http://exchangepedia.com/blog/2008/09/configuring-deleted-item-retention.html
Regards Chen V [MCTS SharePoint 2010] -
Excel 2010 Synchronize List with SharePoint List using VBA
I have used and loved the interaction between Excel and SharePoint for many generations of both solutions. It's a wonderful opportunity to integrate the familiarity and simplicity of Excel (formatting, ease of use, availability) with the data storage
and centralized list capabilities of SharePoint. Right?
When upgrading to Excel 2010, I have noticed with much dismay that much of the inherent easy to use features of previous versions were effectively stripped from this newest version. Much research, time and energy has been spent working around and resolving
the deficiency. One Microsoft based article,
http://support.microsoft.com/kb/930006, has provided the mechanics behind utilizing the "hidden" functionality... although, this capability to use VBA to create the synchronized list was available in previous versions. However, once Microsoft
published this article to this "hidden" functionality... I feel that the behavior should be supported by Microsoft in some way. OK?
Revised instructions to reproduce the problem:
1. Create a SharePoint list with 20 dummy records.
- Note the List Name ##LIST_NAME##
- Note the View GUID ##VIEW_GUID##
- Note SharePoint Base URL ##BASE_URL##
2. REVISED... In Excel 2010, save the file as Compatible "Excel 97-2003 Workbook". Close the file and reopen. Create a connected table (ListObject) in Excel using the article above to the SharePoint list. Use Sample VBA code
below:
Sub LinkedSharePointList()
ActiveSheet.ListObjects.Add SourceType:=xlSrcExternal,_
Source:=Array(##BASE_URL## & "/_vti_bin", ##LIST_NAME##, _
##VIEW_GUID##), LinkSource:=True, Destination:=Range("A1")
End Sub
3. OOPS REVISED this item. The problem is actually with ROW 21... So, update record on row 21... (no matter where the table is located... (if the "Destination" is "A1", then the problem is with ID=20, but if the Table is
shifted down to say A12, then ID=9 on row 21). Anyway... make a simple change to that record... and you'll see the ID immediately change.... as if it's a NEW record. WEIRD! Note: If the sheet is protected, then an error is displayed
indicating that a "read-only" record cannot be updated (referring to the ID cell in column A for the current row).
4. Now "synchronize" the list with excel. The former record is still in the list unchanged AND there is a NEW record in the list holding the changes. There are a number of problems that seem to ONLY occur when something changes to ROW
21.... Next, try to copy/paste multiple records across multiple rows that intersect with ROW 21. Yikes!!
I look forward to hearing others' experience!
Thanks!
MarkHere are some things that you can try (change the code, where appropriate):
Private Sub CreateList()
Dim folder As folder
Dim f As File
Dim fs As New FileSystemObject
Dim RowCtr As Integer
RowCtr = 1
Set folder = fs.GetFolder("http://excel-pc:43231/Shared Documents/Forms/") '<=Variable Location
For Each f In folder.Files
Cells(RowCtr, 1).Value = f.Name
RowCtr = RowCtr + 1
Next f
End Sub
Sub ListAllFile()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim pth As String
Dim WBn As Workbook
Dim ObCount As Long
Dim FileNme As String
Application.ScreenUpdating = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object associated with the directory
Set objFolder = objFSO.GetFolder("\\excel-pc:43231\Shared Documents\Forms\")
'** You'll need to specify your path here. By removing the http: from the path, the code liked it & found the folder. It wasn’t working previously ***
pth = "http://excel-pc:43231/Shared Documents/Forms/"
'** You'll need to specify your path here. The reason I’ve done this separately is because the path is not recognised otherwise when trying to specify it with workbook.open & using the value set for objFolder **
ObCount = objFolder.Files.Count
'** counts the number of files in the folder
'Loop through the Files collection
For Each objFile In objFolder.Files
Nm1 = Len("http://excel-pc:43231/Shared Documents/Forms/")
'** You'll need to specify your path here **
Nm2 = Len(objFile) - Nm1
FileNme = Right(objFile, Nm2)
'** I’ve done this part to find out/set the file name**
Set WBn = Workbooks.Open(pth & FileNme, , , , Password:="YourPassword")
'** opens the first file in the library – if there is no password, the remove everything from - , , , , Password:="Password1" – leaving the close bracket ‘)’
Application.ScreenUpdating = False
'** optional – you can leave the screen updating on
'<< Your coding here>>
'** The file is now open. Enter whatever code is specific to your spreadsheets.
Next
'** goes to next file within your sharepoint folder
End Sub
Sub SharePoint()
Dim xlFile As String, xlFullFile As String
Dim xlApp As Excel.Application
Dim wb As Workbook
xlFile = "\\excel-pc:43231\Shared Documents"
'http://excel-pc:43231/Shared Documents/
'****----denotes the path.(i.e) u give the path as windows search.Don't use "\" at the end.
'In the sharepoint path %20 denotes space.so u remove that and use space .
Set xlApp = New Excel.Application
xlApp.Visible = True
xlFullFile = GetFullFileName(xlFile, "Book") 'ANZ denotes starting characters of the file.
xlFile = xlFile & "\" & xlFullFile
Set wb = xlApp.Workbooks.Open(xlFile, , False)
'Once the workbook is opened u can do ur code here
wb.Close False
End Sub
Function GetFullFileName(strfilepath As String, _
strFileNamePartial As String) As String
Dim objFS As Variant
Dim objFolder As Variant
Dim objFile As Variant
Dim intLengthOfPartialName As Integer
Dim strfilenamefull As String
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strfilepath)
'work out how long the partial file name is
intLengthOfPartialName = Len(strFileNamePartial)
For Each objFile In objFolder.Files 'Instead of specifying the starting characters of the file you can directly loop through all files in the folder .
'Test to see if the file matches the partial file name
If Left(objFile.Name, intLengthOfPartialName) = strFileNamePartial Then
'get the full file name
strfilenamefull = objFile.Name
Exit For
Else
End If
Next objFile
Set objFolder = Nothing
Set objFS = Nothing
'Return the full file name as the function's value
GetFullFileName = strfilenamefull
End Function
Sub SrchForFiles()
' Searches the selected folders and sub folders for files with the specified (xls) extension.
'ListTheFiles 'get the list of all the target XLS files on the SharePoint Directory
Dim i As Long, z As Long, Rw As Long, ii As Long
Dim ws As Worksheet, dd As Worksheet
Dim y As Variant
Dim fldr As String, fil As String, FPath As String
Dim LocName As String
Dim FString As String
Dim SummaryWB As Workbook
Dim SummaryWS As Worksheet
Dim Raw_WS As Worksheet
Dim LastRow As Long, FirstRow As Long, RowsOfData As Long
Dim UseData As Boolean
Dim FirstBlankRow As Long
'grab current location for later reference, for where to paste final data
Set SummaryWB = Application.ActiveWorkbook
Set SummaryWS = Application.ActiveWorkbook.ActiveSheet
y = "xls"
fldr = "\\excel-pc:43231\Shared%20Documents\Forms\AllItems.aspx"
FirstBlankRow = 2
'asd is a 1-D array of files returned
asd = ListFiles(fldr, True)
Set ws = Excel.ThisWorkbook.Worksheets(1) 'list of files
ws.Activate
ws.Range("A1:Z100").Select
Selection.Clear
On Error GoTo 0
For ii = LBound(asd) To UBound(asd)
Debug.Print Dir(asd(ii))
fil = asd(ii)
'open the file and grab the data
Application.Workbooks.Open (fil), False, True
'Get file path from file name
FPath = Left(fil, Len(fil) - Len(Split(fil, "\")(UBound(Split(fil, "\")))) - 1)
'Get file information
If Left$(fil, 1) = Left$(fldr, 1) Then
If CBool(Len(Dir(fil))) Then
z = z + 1
ws.Cells(z + 1, 1).Resize(, 6) = _
Array(Dir(fil), LocName, RowsOfData, Round((FileLen(fil) / 1000), 0), FileDateTime(fil), FPath)
DoEvents
With ws
.Hyperlinks.Add .Range("A" & CStr(z + 1)), fil
'.FoundFiles(i)
End With
End If
End If
'Workbooks.Close 'Fil
Application.CutCopyMode = False 'Clear Clipboard
Workbooks(Dir(fil)).Close SaveChanges:=False
Next ii
With ws
Rw = .Cells.Rows.Count
With .[A1:F1]
.Value = [{"Full Name","Location","Rows of Data","Kilobytes","Last Modified", "Path"}]
.Font.Underline = xlUnderlineStyleSingle
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
End With
.[G1:IV1 ].EntireColumn.Hidden = True
On Error Resume Next
'Range(Cells(Rw, "A").End(3)(2), Cells(Rw, "A")).EntireRow.Hidden = True
Range(.[A2 ], Cells(Rw, "C")).Sort [A2 ], xlAscending, Header:=xlNo
End With
End Sub
Function ListFiles(ByVal Path As String, Optional ByVal NestedDirs As Boolean) _
As String()
Dim fso As New Scripting.FileSystemObject
Dim fld As Scripting.folder
Dim fileList As String
' get the starting folder
Set fld = fso.GetFolder(Path)
' let the private subroutine do all the work
fileList = ListFilesPriv(fld, NestedDirs)
' (the first element will be a null string unless the first ";" is removed)
fileList = Right(fileList, Len(fileList) - 1)
' convert to a string array
ListFiles = Split(fileList, ";")
End Function
' private procedure that returns a file list
' as a comma-delimited list of files
Function ListFilesPriv(ByVal fld As Scripting.folder, _
ByVal NestedDirs As Boolean) As String
Dim fil As Scripting.File
Dim subfld As Scripting.folder
' list all the files in this directory
For Each fil In fld.Files
'If UCase(Left(Dir(fil), 5)) = "MULTI" And fil.Type = "Microsoft Excel Worksheet" Then
If fil.Type = "Microsoft Excel Worksheet" Then
ListFilesPriv = ListFilesPriv & ";" & fil.Path
Debug.Print fil.Path
End If
Next
' if requested, search also subdirectories
If NestedDirs Then
For Each subfld In fld.SubFolders
ListFilesPriv = ListFilesPriv & ListFilesPriv(subfld, NestedDirs)
Next
End If
End Function
Finally . . .
Sub ListFiles()
Dim folder As Variant
Dim f As File
Dim fs As New FileSystemObject
Dim RowCtr As Integer
Dim FPath As String
Dim wb As Workbook
RowCtr = 1
FPath = "http://excel-pc:43231/Shared Documents"
For Each f In FPath
'Set folder = fs.GetFolder("C:\Users\Excel\Desktop\Ryan_Folder")
'For Each f In folder.Files
Cells(RowCtr, 1).Value = f.Name
RowCtr = RowCtr + 1
Next f
End Sub
Sub test()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Users\Excel\Desktop\Ryan_Folder")
'Set colSubfolders = objFolder.SubFolders
'For Each objSubfolder In colSubfolders
Cells(RowCtr, 1).Value = f.Name
RowCtr = RowCtr + 1
'Next
End Sub
Ryan Shuell
Maybe you are looking for
-
Subject in the mail truncating after 50 character
hi friends I am working on ESS Leave request. Mail is going to external mail ids. The subject line after 50 character the letters are getting truncated. We are in SAP_BASIS = SAPKA70015. I have already checked the notes 958426,975947 this is implem
-
BO Edge 4.0 Installer stuck on "Run command-line executable"
Hi, Our BO Edge BI Server 4.0 Installer on Windows Server 2008R2 is stuck on one of the last steps; "Run command-line executable". Before is was stuck on "WaitForCMSForTheFirstTime". We upped the RAM to 16GB and then the installer went past this, but
-
Dell Latitude X300 screen problem
Hello everyone, I recently installed Archlinux on my 2nd computer, a Dell Latitude X300. Everything just works fine, the only problem atm I have is that when I close my screen over keyboard for a couple of minutes and then re-open it, it displays som
-
my iphone is in recovery mode
-
User List applet takes a lot of time to load
Hi, There are around 5000 users in identity manager. When I login into identity manager and click on 'list accounts', it takes a lot of time for the User List applet to load. I had enabled trace in the user form that is associated with the user. And