从excel打开word文档,在同一页面上打印选择和字符串(Opening a word doc from excel, print a selection and a string on the same page)
我有一个数据库与Word文档。 文件名像000001,000002 ......
我已成功编写了一个宏,用于打开这些文档,直到找到值为止进行选择,然后打印该选择,然后再次关闭文档并转到下一个文档。 (见下面的代码)
有一件事我想额外做,但我无法弄清楚。 我希望在此选项下打印“End”(在同一页上)。 但是我想在不改变文件的情况下做到这一点。
我不想更改文档,因为需要使用选择打印的值来自用户窗体文本框,并且每次都会有所不同。 但是如果有人能够帮助我,你可以举一个例子来结束这个词
添加了一张图片,上面有我在找的东西
这是我现在的代码:
Dim i As Long, wdApp As Object, wdDoc As Object, wdRng As Object Set wdApp = CreateObject("Word.Application") With wdApp .Visible = True For i = 1 To 9 Set wdDoc = .Documents.Open("\\path\" & Format(i, "000000") & ".NET", False, True, False) With wdDoc Set wdRng = .Range(0, 0) With .Range With .Find .Text = "ENDLIST" .Forward = True .MatchWholeWord = True .MatchCase = True .Execute End With If .Find.found = True Then wdRng.End = .Duplicate.Start wdRng.Select wdDoc.PrintOut , Range:=1 End If End With .Close False End With Next .Quit End With Set wdRng = Nothing: Set wdDoc = Nothing: Set wdApp = Nothing End Sub
这是可能的,如果是的话,是否有人可以帮助我去
I have a database with word docs. The filenames are like 000001, 000002......
I have successfully written a macro that opens these documents, makes a selection until a value is found, print this selection and then close the document again and move on to the next. (see code below )
There is one thing I want to do extra, but I can't figure it out. I want the word "End" printed under this selection (on the same page). But I want to do this without making any change in the documents.
I don't want to change the documents because the value that needs to be printed with the selection comes from an userform textbox and is different every time. But if someone can help me, you can give an example with the word end
Added a picture above off what im looking for
this is my code now:
Dim i As Long, wdApp As Object, wdDoc As Object, wdRng As Object Set wdApp = CreateObject("Word.Application") With wdApp .Visible = True For i = 1 To 9 Set wdDoc = .Documents.Open("\\path\" & Format(i, "000000") & ".NET", False, True, False) With wdDoc Set wdRng = .Range(0, 0) With .Range With .Find .Text = "ENDLIST" .Forward = True .MatchWholeWord = True .MatchCase = True .Execute End With If .Find.found = True Then wdRng.End = .Duplicate.Start wdRng.Select wdDoc.PrintOut , Range:=1 End If End With .Close False End With Next .Quit End With Set wdRng = Nothing: Set wdDoc = Nothing: Set wdApp = Nothing End Sub
Is this possible, and if it is can someone please help me going
原文:https://stackoverflow.com/questions/41116050
最满意答案
var sorted = list.OrderBy(x => x.URL + x.FileName);
您可以根据需要填充URL,或者执行您需要的任何其他操作。
var sorted = list.OrderBy(x => x.URL + x.FileName);
You can pad the URL if desired, or do just about any other operation you need.
相关问答
更多-
有没有办法合并多个属性,然后通过LINQ排序?(Is there a way to merge multiple properties and then sort via LINQ?)[2023-11-21]
var sorted = list.OrderBy(x => x.URL + x.FileName); 您可以根据需要填充URL,或者执行您需要的任何其他操作。 var sorted = list.OrderBy(x => x.URL + x.FileName); You can pad the URL if desired, or do just about any other operation you need. -
如果我正确地理解了你的话: var result = unsortedFlights .OrderByDescending(f => totalCityFilters[f.DestinationID]) .ThenBy( f => f.FinalPrice) .ToList(); 如果totalCityFilters的值是您想先订购的数量。 If i have understood you correctly: var resu ...
-
你需要做的是首先弄平学生 - >学科关系,然后你就可以对两者进行排序: var list = con.Students.Include(e => e.ExamScores.Select(s => s.Subjects)) .SelectMany(student => student.ExamScores.Select(score => new { Student = student, Score = score })) .OrderBy(x => x.Student.Name) .T ...
-
LINQ中没有这样的方法。 而且我认为不可能将现有方法结合起来以达到您想要的效果(如果是的话,这会过于复杂)。 但是自己实施这种方法并不难: static IEnumerable
Merge (this IEnumerable first, IEnumerable second, Func predicate) { // valid ... -
使用LINQ在多个表中按多个属性有条件地排序元素(Conditionally sorting elements by multiple properties in multiple tables with LINQ)[2020-01-18]
我想这可以解决这个问题: model.Pages = db.Pages .OrderBy(p=>p.Navigation != null ? p.Navigation.Index : Int32.MaxValue) .ThenBy (p=>p.Title) .ThenBy (p=>p.PageID) .ToList(); 或者如果您喜欢这种语法 var query = from p in db.Pages orderby p.Navigation != null ? ... -
有没有办法对属性进行排序而不必在其上放置“订单”?(Is there a way to sort properties without having to put an “Order” on them?)[2021-07-30]
好的,我明白了。 我们可以改变Attribute类。 public class Items : Attribute { public bool Last { get; set; } public Items(bool last = false) { this.Last = last; } } 然后改变主要班级 public class client { [Items] public string fName { get; set; } ... -
如何使用具有不同类的多个属性的linq`Exce`?(How to use linq `Except` with multiple properties with different class?)[2023-06-08]
您已经说过只需要来自testListA这些对象: testListB没有匹配的ProductID 存在mathing ProductID ,但具有不同的Category 所以,你的过滤器必须是: !testListB.Any(b => a.ProductID == b.ProductID && a.Category == b.Category) 因此,将代码更改为: testListA.Where(a => !testListB.Any(b => a.ProductID == b.ProductID && ... -
您的问题的解决方案是GroupBy 。 首先根据选定的列排序对象: var ordered = purchaseOrders.OrderBy(po => po.ShippingAddress); 您需要根据主要订单对订单进行分组。 我假设顺序是一个字符串,所以我创建了一个字符串IEqualityComparer如下所示: class OrderComparer : IEqualityComparer
{ public bool Equals(string x, string y) ... -
下面的内容仍然相当丑陋,我相信它可以通过一些工作带入更加流线型的形状,但是现在这似乎可以完成这项工作: public static void MergeXml() { var xdoc1 = XDocument.Load(@"c:\temp\test.xml"); var xdoc2 = XDocument.Load(@"c:\temp\test2.xml"); var d1Targets = xdoc1.Descendants("third"); var d2Selecti ...
-
首先为您的类实现IEqualityComparer
,并根据您感兴趣的字段比较对象。例如,实现Equals方法,如下所示: public bool Equals(MyType a, MyType b) { return a.FileName == b.FileName && a.MD5 == b.MD5; } 然后只需调用Except方法并传递比较器: var listC = listA.Except(listB, new MyEqualityComparer()); 或者如果你在课堂上实 ...