word-vba

Unexpected results from typename

僤鯓⒐⒋嵵緔 提交于 2019-12-17 17:12:16
问题 I am getting some unexpected results from typename and am stumped. Hopefully some can point me in the right direction. Private Sub T() Dim d As Word.Document Dim s As String Dim c As Collection Dim i As Long Dim o As Object Set d = ActiveDocument s = "X" Set c = New Collection Debug.Print "d is a " & TypeName(d) Debug.Print "s is a " & TypeName(s) Debug.Print "c is a " & TypeName(c) c.Add (d) c.Add (s) For i = 1 To c.count Debug.Print "Item " & i & " of the collection is a " & " " & TypeName

How to get the email address of the current logged-in user?

梦想的初衷 提交于 2019-12-17 16:39:18
问题 I'm new to VBA and trying to get an automated word document working. At the moment there is a Button in the document that which upon pressing, will fire off an email with the document attached. However I need to also get the email address of the current user sending the email, so I can place it inside the document before sending it off. My searches on the internet have not resulted in any usable code that meets my situation. My current code is below. Set OL = CreateObject("Outlook.Application

Extract Data from Word Document to an Excel SpreadSheet

寵の児 提交于 2019-12-17 09:59:41
问题 I have a requirement to extract a value from a word document on a daily basis and write it to an excel workbook. I currently do this manually and it is border line regarding the most efficient method for me Using Excel file create a vba script and add any word document references. 2 Using the word navigate to the table “9. STOCKS...” (extracted example below – Appendix A) and read the Diesel (ltrs) daily usage highlighted in red. 3.Write this value to a spreadsheet cell. The date for this

Sending and receiving data via POST in Microsoft Word 2011 for OSX

試著忘記壹切 提交于 2019-12-14 04:27:27
问题 I am trying to port a macro that we have working for MS Word on Windows that uses a website to generate an equation image and returns that image for insertion into a document. The current (working on Windows) call is below. When I use the same call in OSX, I receive an error 429 stating "ActiveX component can't create object". ' Create an xmlhttp object. Set w_page = CreateObject("Microsoft.XMLHTTP") ' Open the connection to the remote server. w_page.Open "POST", WebAdd, False ' Indicate that

Word VBA: iterating through characters incredibly slow

人走茶凉 提交于 2019-12-14 03:57:49
问题 I have a macro that changes single quotes in front of a number to an apostrophe (or close single curly quote). Typically when you type something like "the '80s" in word, the apostrophe in front of the "8" faces the wrong way. The macro below works, but it is incredibly slow (like 10 seconds per page). In a regular language (even an interpreted one), this would be a fast procedure. Any insights why it takes so long in VBA on Word 2007? Or if someone has some find+replace skills that can do

VBA slows over time - can I load my object into memory to speed things up?

ぃ、小莉子 提交于 2019-12-14 03:34:23
问题 I'm running vba in excel to read paragraphs from a word document. The code works fine, however, I'm reading 10000 paragraphs and by the time I get to the end the loop is crawling. I wanted to try reading the word doc into memory then attempting the loop to see if it speeds up. The thing is that I'm not sure how to do this. Any suggestions? Here is what I currently have Set wdDoc = GetObject(wdFileName) Set myParas = wdDoc.Paragraphs ParCount = myParas.Count For X = 0 To ParCount ' ParCount is

deleting certain lines in ms word 2007

筅森魡賤 提交于 2019-12-14 03:16:52
问题 I would like to delete certain lines from my word document using a VBA macro. Basically the (block of) text to be deleted (and replaced by "***") follows a certain pattern (below). Bottom of Form perma-link Top of Form save Bottom of Form [+] .... [–] .... Top of Form "...." represents text that changes every block, but for sure the line starts with "[+]" or "[-]". Please suggest a suitable macro EDIT: In the screenshot, I would like to keep the text in yellow and delete the rest. (in the

Hyperlink to PDF file page from Word 2013

一笑奈何 提交于 2019-12-14 02:34:21
问题 According to different sources one should be able to hyperlink to a specific page in a PDF-file from other applications by appending the suffix: #page=, for example: C:\Temp\Examplefile.pdf#page=5 This is not working from Word 2013. I have read that it depends on what application and version installed as PDF-file reader on the client and file extension associations, but I think it is an issue with Word 2013. On the same computer I can successfully hyperlink to a PDF page from an HTML-file by

Run-time error 459 when using WithEvents with a class that implements another

南笙酒味 提交于 2019-12-14 00:22:08
问题 I am developing a VBA project in Word and have encountered a problem with handling events when using a class that implements another. I define an empty class, IMyInterface : Public Sub Xyz() End Sub Public Event SomeEvent() And a class, MyClass that implements the above: Implements IMyInterface Public Event SomeEvent() Public Sub Xyz() ' ... code ... RaiseEvent SomeEvent End Sub Private Sub IMyInterface_Xyz() Xyz End Sub If I create a third class, OtherClass , that declares a member variable

Macro to automatically number word documents

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 19:40:43
问题 I've combined 3000 documents into one word file which are all separated by a section break. Is there a Macro that would automatically number each document along the lines of 0001, 0002 etc.? 回答1: Yes, here is the code that: finds section break (^b) changes it for manual page break (^m) and the number of it. Further information, about finding wildcards, special characters etc in Word (like ^b - section break; ^m - manual break): Find and replace text or other items (support.office.com) Here is