![]() |
Mail Merge Object Value
Hi there,
I have a word template that retrieve a project value using our software. However, within the word document I have an excel document. The excel document within the word document should do some calculations based on the project value in the word template. I do have the value in the word document but need to know how to get the value in the excel spreadsheet within the word document. Please note that the project value is a mail merge object. my question to you is: how do i get the value from the microsoft word file in the excel spreadsheet cell A2. Thanks |
Mail Merge Object Value
You will need a macro in your WORD document along these lines:
Sub Write_To_Excel() On Error Resume Next Set MySpreadsheet = GetObject(, "Excel.Application") If Err Then Set MySpreadsheet = CreateObject("Excel.Application") End If ' INPATH is directory path ' XLSNAME is w/book name inpath = "C:\Documents and Settings\John\Desktop\" xlsname = "MM.xls" wordvalue = "From Word to A2" wbook = inpath & "\" & xlsname Set MySpreadsheet = GetObject(wbook) With MySpreadsheet .Application.Visible = True .Parent.Windows(xlsname).Visible = True .Application.Worksheets(Worksheet_name).Activate .Application.Cells(2, 1).Value = wordvalue ' Get value from A2 End With End Sub HTH "pjerling" wrote: Hi there, I have a word template that retrieve a project value using our software. However, within the word document I have an excel document. The excel document within the word document should do some calculations based on the project value in the word template. I do have the value in the word document but need to know how to get the value in the excel spreadsheet within the word document. Please note that the project value is a mail merge object. my question to you is: how do i get the value from the microsoft word file in the excel spreadsheet cell A2. Thanks |
Mail Merge Object Value
Thanks Toppers!
I pass through the word at the moment, will start cracking on to get the value in! "Toppers" wrote: You will need a macro in your WORD document along these lines: Sub Write_To_Excel() On Error Resume Next Set MySpreadsheet = GetObject(, "Excel.Application") If Err Then Set MySpreadsheet = CreateObject("Excel.Application") End If ' INPATH is directory path ' XLSNAME is w/book name inpath = "C:\Documents and Settings\John\Desktop\" xlsname = "MM.xls" wordvalue = "From Word to A2" wbook = inpath & "\" & xlsname Set MySpreadsheet = GetObject(wbook) With MySpreadsheet .Application.Visible = True .Parent.Windows(xlsname).Visible = True .Application.Worksheets(Worksheet_name).Activate .Application.Cells(2, 1).Value = wordvalue ' Get value from A2 End With End Sub HTH "pjerling" wrote: Hi there, I have a word template that retrieve a project value using our software. However, within the word document I have an excel document. The excel document within the word document should do some calculations based on the project value in the word template. I do have the value in the word document but need to know how to get the value in the excel spreadsheet within the word document. Please note that the project value is a mail merge object. my question to you is: how do i get the value from the microsoft word file in the excel spreadsheet cell A2. Thanks |
All times are GMT +1. The time now is 03:34 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com