I can add a bullet in word document through vb.net by using applybulletDefault() method but how can i remove it in next line??
Selection.Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph will set you back to a normal paragraph.
When I'm writing VB code write to a Word Document I often use Record Macro in Word to do the actions as a user would, Stop Macro recording, Edit the macro, copy and paste into VB and massage we required.
Related
I want code a search function via VBA that searches for a specific text and highlights the first result in PowerPoint (like the normal search window, that can be opened with Ctrl + F).
I want to code this in VBA, because I want to search for multiple texts (I have a sub, where I deliver the search text as parameter) and do not want to have to type the search texts manually in the search window.
Having a sub with a parameter is not the problem.
The problem is highlighting the first result.
I found this code here (the first answer in this topic):
powerpoint search box vba
The only thing that I need is to switch to the slide and highlight the text.
A very simple question I suppose, but I reached a deadlock with this:
I have to use a .bat file to imput plain text data into the right cells an excel sheet with lots of graphics content, vba parts, macro that deactivate "normal" EXCEL buttons and functions, password to protect the pre-typed functions, sudden and unexpected changes in the version of the "taget file", and many other complications...
My need is to be absolutely sure that the .bat is sending the sequence into the right version of the .xlsm file.
To do that I want to store the last known filename (that include the file version) in the .bat file, and I want to take focus on the excel window in wich the data have to be written ONLY IF the title of the excel window is exactly the same.
So Here is the question: How to get the focus on a specific open file from a .bat file?
You can't. If you wanted to use vbscript or jscript you could do what you want in a command prompt in an unreliable way (but it will work most circumstances).
Excel has it's own forms.
Put column headers in a row. Put selection in same row. Alt + D, O.
Plus you can make Excel only allow entries on some cells, like a invoice form.
Right click cell, Properties, Protection, Unlock. Then Alt + T, P, P.
Word has it's own forms similar to Excel (Word is also a spreadsheet).
Excel VBA language (and VBScript too) has input box command.
Sub main()
Sheet1.Range("A1").Value2 = InputBox("enter Value")
End Sub
I have a simple macro that reads Strings from a .csv file. I want to place (Replace) those Strings into the body of an email. The email will be opened from a template, so I want the fields in the template, and then have my macro start a new email from the template and replace the fields with the String variables.
I'm not finding anything posted that shows how to format such a field in the body of the email.
A link to a reference would be helpful.
The rest of the story: The email template body was pasted from a Word mailmerge document, so it already has mailmerge fields in the correct locations. There is probably a way to make mailmerge work in Outlook, but mailmerge in Word was problematic, and I don't know what makes mailmerge tick, so when it broke on a user's computer I had to rebuild the merge document, etc. Now we're switching to email instead of a printed Word document, and I'm more comfortable with writing a macro to explicitly place the data. I haven't done much programming in vba, so I'm picking up the syntax piece by piece as I go.
There are no fields. Your Outlook .oft template should contain unique string placeholders.
Once you .CreateItemFromTemplate, replace the unique string placeholders.
MyMail.HTMLBody = Replace(MyMail.HTMLBody, "UniqueStringPlaceholder_1", "csvstring_1")
You will likely work out some kind of loop.
I have a word document that is littered with hyperlinks. The links themselves work fine, but for some reason, most of them are not blue anymore! All I'm really looking to do is try to find a way to use a macro or something to go through the document and add the "Hyperlink" style format to each hyperlink.
I tried to edit some macro code myself (one that changes all the links URLs), but I keep making the problem worse! I used to be good at VBScript, but it's been ages since then.
Any easy solution that doesn't involve manually changing each style?
As a side note, all of them currently are in "Normal" style, for some reason.
Try to execute this VBA script (best in debugging mode using the F8 key - have VBA and Word windows side by side so you can see what's happening):
Sub FormatLinks()
Dim H As Hyperlink
For Each H In ActiveDocument.Hyperlinks
H.Range.Select ' (A)
Selection.ClearFormatting ' (B)
H.Range.Style = ActiveDocument.Styles("Hyperlink") ' (C)
Next H
End Sub
This will
cycle through all hyperlinks in your document (A),
remove any formatting on the underlying text (B) and
assign the undrelying text to style "Hyperlink" (C)
(C) is not strictly necessary, as (B) should already sanitize your document, but maybe better to have hyperlinks really assigned to style "Hyperlink" because you may want to change the style later on.
I'm trying to get the formatted text of the appointment item, I've searched everywhere and most places suggest getting the word document of the appointment item :
Word.Document wd = (Word.Document) (item as Outlook.AppointmentItem).GetInspector.WordEditor;
So I do that and I get the word document. But no where does it tell you what to actually do with this word document once you get it. How do I get the formatted text from the word document now?
UPDATE:
To anyone else searching for this answer in the future. I figured out how to do this in ol2007
1) First have have to get the word document from the appoint item via the WordEditor variable.
2) Then you have to use the select and copy functions from the word document to copy the RTF text into your clipboard.
3) make a richtextbox and use the richtextboc paste function to paste whats in the clipboard into your richtextbox.
4) now from the richtextbox you can access the .Rtf function which will now give you the RTF of the appointmentItem.
From my searching this method is the easiest way but you have to take over the clipboard which isn't ideal. There is a second way that I read about that is to save the word document in step 1 into an actually RTF file on your computer and then read in that RTF file.
and third way I suppose to do it would be to parse out the word document in step 1 using the Range.FormattedText function.
UPDATE: To anyone else searching for this answer in the future. I figured out how to do this in ol2007
1) First have have to get the word document from the appoint item via the WordEditor variable.
2) Then you have to use the select and copy functions from the word document to copy the RTF text into your clipboard.
3) make a richtextbox and use the richtextboc paste function to paste whats in the clipboard into your richtextbox.
4) now from the richtextbox you can access the .Rtf function which will now give you the RTF of the appointmentItem.
From my searching this method is the easiest way but you have to take over the clipboard which isn't ideal. There is a second way that I read about that is to save the word document in step 1 into an actually RTF file on your computer and then read in that RTF file.
and third way I suppose to do it would be to parse out the word document in step 1 using the Range.FormattedText function.