![]() |
Opening Word in Excel
Hi. I'm trying to open a word document via a userform button so that I can
mailmerge from Excel. Anyone know how to do that? |
Opening Word in Excel
This (can be) a big subject so here is just a hint. You have to reference the word object library in the VBA referemces which will give you access to the word objects. I tend to develop the code for controlling the word documnet in word and then paste it into Excel. I find it easier to test and debug that way. If I am working with several word documents I either set up the code for handling these as seperate routines in Excel (so that if I change the word document the code is clearly recognisable. Or keep the code in the word document and pass the values over by wetting up properties. Without knowing clearly what you are trying to do and your level of expertise it is difficult to know how to answer this. regards -- tony h ------------------------------------------------------------------------ tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074 View this thread: http://www.excelforum.com/showthread...hreadid=513121 |
Opening Word in Excel
Here are some sources of information you can consult:
Microsoft Office 97 Automation Help File Available (Q167223) http://support.microsoft.com/default...b;EN-US;167223 Microsoft Office 2000 Automation Help File Available (Q260410) http://support.microsoft.com/default...b;EN-US;260410 Microsoft Office XP Automation Help File Available (Q302460) http://support.microsoft.com/default...b;EN-US;302460 http://msdn.microsoft.com/library/en...ortal_7l45.asp Automation Programmer's Reference http://support.microsoft.com/default...b;EN-US;253235 FILE: OFFAUTMN.EXE Discusses Office 97 and 2000 Automation and Provides Sample Code -- Regards, Tom Ogilvy "tony h" wrote in message ... This (can be) a big subject so here is just a hint. You have to reference the word object library in the VBA referemces which will give you access to the word objects. I tend to develop the code for controlling the word documnet in word and then paste it into Excel. I find it easier to test and debug that way. If I am working with several word documents I either set up the code for handling these as seperate routines in Excel (so that if I change the word document the code is clearly recognisable. Or keep the code in the word document and pass the values over by wetting up properties. Without knowing clearly what you are trying to do and your level of expertise it is difficult to know how to answer this. regards -- tony h ------------------------------------------------------------------------ tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074 View this thread: http://www.excelforum.com/showthread...hreadid=513121 |
Opening Word in Excel
In my situation, I have Word document names in a spreadsheet. All docs
listed are in the same folder as the workbook. This code gets the doc name from the ActiveCell, and the doc file path from the workbook path. You will need to adjust as required (you may want to use the BuiltIn FileOpen dialog instead). HTH Ed Sub FindDoc() ' ****** ' NOTE: Use only _one_ of the bindings below. ' Comment out the other one. I have the early binding ' to help code, but use the late binding to run ' because I don't know the user's versions. 'Dim WD As New Word.Application Dim WD As Object ' ******* Dim doc As String Dim Fname As String Dim Fpath As String Err.Clear ' Get file path Fpath = ThisWorkbook.Path Sheets("Sheet1").Activate ' Get doc name from list page Fname = ActiveCell.Text ' Open doc doc = Fpath & "\" & Fname & ".doc" On Error Resume Next Set WD = GetObject(, "Word.Application") If Err.Number < 0 Then Set WD = CreateObject("Word.Application") End If Err.Clear On Error GoTo 0 WD.Documents.Open doc WD.Visible = True WD.Quit Set WD = Nothing End Sub "Jeralc" <u18775@uwe wrote in message news:5bf5e9a660038@uwe... Hi. I'm trying to open a word document via a userform button so that I can mailmerge from Excel. Anyone know how to do that? |
All times are GMT +1. The time now is 02:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com