Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I call a word macro from excel? 1

Status
Not open for further replies.

ceyhorn

Programmer
Nov 20, 2003
93
0
0
US
How do I call a word macro from excel?

thanks,
chris
 
Hi Chris
add this to your excel module and run. Don't forget to change the text in green to your filenames & macronames

You Will also need to add some code to the end of your word macro to close word so it can return to run the rest of your excel macro.


Sub runwordmacro()

Set wd = CreateObject("word.application")
wd.Application.documents.Open "yourfilenamepath\filename"
wd.Application.Visible = True
wd.Application.Run "modulename.macroname"
Set wd = Nothing

End Sub


HTH

Matt
[rockband]
 
It worked like a charm, thanks so much.

I do have one more question though. I have written some code that goes through all of the word files in a specified folder. It opens them and then renames them. Most of the files it opens and changes them just fine, but when on some of them it prompts me to convert them to rtf files and then it will open them, is there anyway to automatically have vb click ok for me when the box pulls up?

Thanks so much again,
chris
 
Hi Chris,

You could try playing around with

ActiveDocument.SaveAs FileName:="filename",fileFormat:=wdFormatDocument

If you are still having problems post back with which filetypes it is prompting you on and I will have a look further into it for you.

Cheers,

Matt
[rockband]
 
Chandlm,

What needs to be done to go from Word to Excel? I just need to open an Excel File from word but not sure of the syntax.

Rib

I know a little about nothing and even less about everything.
 
NEVERMIND

I was missing the visible statement.

What's the difference betweening Dimming the variable as an Excel application and creating an object?

Sub OpenMyFile()
Dim xl As New Excel.Application
xl.Application.Workbooks.Open "H:\MRP Project\F99-Misc & Sleeves.xls" 'opens your excel file
xl.Application.Visible = True ' Shows excel application
Set xl = Nothing
End Sub

Rib

I know a little about nothing and even less about everything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top