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
Related
I need to paste 6000 HTML strings into Word as formatted using VBA. I can do this if I insert an HTML file, but would rather do this with passing a string.
This is the sample HTML I'm using:
<html><body>normal <b>bold</b><br></body></html>
I can get this to work:
Selection.InsertFile FileName:="html test file.htm"
Result: normal bold (this is what I want).
But not this (with the above HTML in the clipboard):
ActiveDocument.Range.PasteSpecial ,,,,WdPasteDataType.wdPasteHTML
With the later, I get error 5342 "the specified data type is unavailable".
In a perfect world, I can just pass a string.
In an imperfect world, I can copy the HTML to the clipboard, then copy the clipboard into Word.
In a sucky world, I can write the HTML to a text file, then insert that file into Word (repeat 6000 times).
Even though this is a one off project, I'd rather learn the efficient way to do this, so any help would be appreciated.
In case it's not clear, this is raw HTML from a database, not copying an already formatted page.
Thanks in advance.
The code posted by GMCB (accepted answer) here will do what you want, based on some short testing:
Injecting RTF code in the Clipboard to paste into MS Word as RTF text via a VBA macro
The main focus of that post is putting RTF-format text into the clipboard, but it also covers populating HTML-format.
The Function Module 'TEXT_CONVERT_XLS_TO_SAP' opens a new empty excel sheet while uploading the file.
Please give me a solution for this. I do not want the empty excel file to be opened.
Usually I use the FM ALSM_EXCEL_TO_INTERNAL_TABLE for Excel-Sheet to internal table conversion. Try it out, it's much easier.
Greeting!
I am attempting to use excel vba to extract a dynamic hyperlink from OR use excel vba to open the dynamic hyperlink in a worksheet. I am able to click the hyperlink and it will open up correctly. So far, I am not able to find any relevant information pertaining to how to extract the URL the hyperlink is pointing to or simply open the hyperlink.
Here is the formula that is used to build the dynamic hyperlink based on a model selection.
=IFERROR(HYPERLINK(VLOOKUP(S.O.P.!$D$3,Models!$C$2:$G$296,4,FALSE), "Click Here to Open Box Label"), "Unable to retrieve part information")
So based on a selection the user makes this formula goes and finds the respective link that will be used to create the hyperlink.
What I want: Using a button - open the file(PDF) to allow the users to easily print the files they need from one button. I am trying to minimize human touches to eliminate the possibility for human errors.
I have also attempted to record a macro to open up the link, but it only takes me to the worksheet that the hyperlink is placed in.
Here are links to other post that were not able to resolve my issue, but provided good information...
Excel VBA Get hyperlink address of specific cell
Extract URL From Excel Hyperlink Formula
Thank you, I look forward to some helpful responses c:
let me know if I need to elaborate or clarify anything!
Any reason you cant run the vlookup in VBA. Then you will have the link address as a string which you can then do what you want with:
Sub GetLink()
Dim ReturnedAddress As String
ReturnedAddress = Application.WorksheetFunction.VLookup(ThisWorkbook.Sheets("S.O.P.").Range("D3"), ThisWorkbook.Sheets("Models").Range("C2:G296"), 4, 0)
end sub
I'm using VBA to create a series of charts in Excel and then copying them into a Word file.
Up till now I've been pasting the charts as pictures, so in Excel I used
ActiveChart.CopyPicture
and then in Word, after selecting the target location:Selection.Paste.
Now I want to change it so the charts will be editable but not linked to the source Excel file.
I copy a chart from Excel using ActiveChart.ChartArea.Copyand look at the paste-special options in Word, the options "use destination theme/keep source formatting & embed workbook" work fine for me:
the chart is editable (also the data is editable which I don't need but is OK) and there is no link to the original Excel file.
BUT - I can't find how to perform this through VBA code. Trying to record this in a macro only give me Selection.Paste - which pastes a linked chart.
I also tried a different approach - pasting a linked chart, and then killing the link. once again, deleting the links in the link editor doesn't get recorded in the macro at all.
Please help with coding any of these two options or suggesting a different approach.
The Range.PasteAndFormat method should work. This takes a WdRecoveryType Enum parameter that lets you specify what kind of result you want.
Selection.PasteAndFormat(wdChart) 'Enum value 14 in case of late binding
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.