I am trying to append contents of a html document(with formatting) at the end of a word document (which already has some contents in it). I am using vba in outlook. Please help. Thanks in advance.
Create a range at the end of the document, then call Range.insertFile.
Related
I prepare a MS Word file with a large amount of news articles, each followed by a full, long clickable hyperlink (e.g. http://www.newssite.com/this-is-the-name-of-the-article.html).
I need to replace all the hyperlinks in the file with a single word: "Link", while keeping their url adresses and click functionality. I can use MS Word "change hyperlink" dialogue to do that, but doing it by hand takes incredible amount of time.
The hyperlinks, however, are not always formatted as 'hyperlink' style. Is there any condition for MS Word Macro replacement that will lookup hyperlinks by their functionality, not by their style or text?
Despite this task seems to be quite common, I could not find anything like it in the web.
Since you have the hyperlinks already created. It should just require looping through the documents hyperlinks collection and changing the 'TextToDisplay' property. This should get you started:
Public Sub ChangeHyperlinksText()
Dim hlink As Hyperlink
For Each hlink In ThisDocument.Hyperlinks
hlink.TextToDisplay = "Link"
Next hlink
End Sub
I am trying to cycle through the bookmarks in a word document by their location.
yes I have seen this: How to get list of all bookmark-elements from a Word document to an array in order by location: VBA / Word
no it didn't work. and for the life of me I am not sure why this doesn't since it is lifted from a MS support page.
Sub cycleBookmarks()
ActiveDocument.Bookmarks.DefaultSorting = wdSortByLocation
Dim bkm As Bookmark
For Each bkm In ActiveDocument.Bookmarks
Next bkm
End Sub
Anybody know how to properly cycle through bookmarks by document location? I don't care about headers and footers (though a complete answer would be nice)
According to this MSDN site DefaultSorting property:
Returns or sets the sorting option for bookmark names displayed in the
Bookmark dialog box (Insert menu). Read/write WdBookmarkSortBy.
Therefore you need to use #Mana solution from the link you provided in your question.
Please help me to on this:
In word VBA i am trying to get the type of data copied in clip board.
how can i check the content type in clipboard using Word VBA.
Thank's
You can use Getformat method in Clipboard Objectto check whether the clipboard has certain type of data... See these links for better clarifications...
http://msdn.microsoft.com/en-us/library/ebwdx8yh%28v=vs.90%29.aspx
http://msdn.microsoft.com/en-us/library/system.windows.forms.dataformats%28v=vs.90%29.aspx
http://msdn.microsoft.com/en-us/library/aa240801(v=vs.60).aspx
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.
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.