I'm using Ms2007
How to open a cpecific file MsWord( example- C:\Myw.doc) form Excel Vba and export(print) the content of specific cells(in Sheet of excel) in specific place in the MsWord
Re: How to open a cpecific file MsWordform Excel Vba
Here is the code to open specfic word file
vb Code:
Private Sub CommandButton1_Click()
WObject
End Sub
Sub WObject()
Dim Wd As Object
Dim Doc As Object
Set Wd = CreateObject("Word.Application")
Set Doc = Wd.Documents.Open("C:\AAA\Test.docx")
Wd.Visible = True
End Sub
After I open the file I want to print the text in cells of excel example:
The Cell(1,1), cell(2,3) in word..
If the cells content "John" and "Tom" .. it will print in the Word sheet. "John" and "Tom"
I hope I'm clear
Re: How to open a cpecific file MsWordform Excel Vba
where do you want john and tom to print?
at the beginning, the end, in a table or at a specific position?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Re: How to open a cpecific file MsWordform Excel Vba
you have to have a criteria to find the correct position, this may be a bookmark, or to find certain text and put before / after or whatever, we can not help without knowing the criteria
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete