ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open Words doc from Excel Macro (https://www.excelbanter.com/excel-programming/352325-open-words-doc-excel-macro.html)

Isham Hamin

Open Words doc from Excel Macro
 
Hi,

New to the usergroup. Question: I'm trying to create an excel macro that
will pickup filename from a spreadsheet and open the file in Words
document, then do more formatting changes to the document. I seems to be
stuck at trying to open a Words document from an excel macro. Any
thoughts? Thanks in advance.

Isham


*** Sent via Developersdex http://www.developersdex.com ***

Jim Thomlinson[_5_]

Open Words doc from Excel Macro
 
Try this... You need to reference your project to the "Microsoft Word ?.?
Object Library". In the VB Editor select Tools - References ...

Sub OpenWordDoc()
Dim appWord As Word.Application

Set appWord = New Word.Application
With appWord
.Visible = True
.Documents.Open "D:\Test.doc"
End With
Set appWord = Nothing
End Sub

--
HTH...

Jim Thomlinson


"Isham Hamin" wrote:

Hi,

New to the usergroup. Question: I'm trying to create an excel macro that
will pickup filename from a spreadsheet and open the file in Words
document, then do more formatting changes to the document. I seems to be
stuck at trying to open a Words document from an excel macro. Any
thoughts? Thanks in advance.

Isham


*** Sent via Developersdex http://www.developersdex.com ***


Gary''s Student

Open Words doc from Excel Macro
 
In A1 put, for example:
C:\third.doc
actually the path and filename of any Word doc. Then enter and run this
small macro:


Sub macro2()

Dim s As String
Dim ss As String
Dim sss As String

ss = "cmd.exe /c "
s = Cells(1, 1).Value
sss = ss & s
x = Shell(sss, 1)
End Sub

You will be in control in Word.
--
Gary's Student


"Isham Hamin" wrote:

Hi,

New to the usergroup. Question: I'm trying to create an excel macro that
will pickup filename from a spreadsheet and open the file in Words
document, then do more formatting changes to the document. I seems to be
stuck at trying to open a Words document from an excel macro. Any
thoughts? Thanks in advance.

Isham


*** Sent via Developersdex http://www.developersdex.com ***



All times are GMT +1. The time now is 03:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com