EricdYoung
asked on
Calling macro in Word from Excel and saving change without save as dialogue box
Good morning,
I have a macro, "hideone", in excel 2010 that is calling another macro in a word 2010 template document, "wordhideone". My problem is I want to save the changes that "wordhideone" is doing without having a save as box come up. Kinda like just hitting the save icon. Please let me know if you need additional information.
Thank you for your help and I hope you are having a good day.
I have a macro, "hideone", in excel 2010 that is calling another macro in a word 2010 template document, "wordhideone". My problem is I want to save the changes that "wordhideone" is doing without having a save as box come up. Kinda like just hitting the save icon. Please let me know if you need additional information.
Sub hideone()
Dim wdApp As Object, newDoc As Object
Dim strFile As String
Dim myDoc As String
myDoc = "Risk Audit Report Template"
strFile = ThisWorkbook.Path & "\" & myDoc & ".docm"
'~~> Establish an Word application object
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set wdApp = CreateObject("Word.Application")
End If
Err.Clear
On Error GoTo 0
wdApp.Visible = False
Set newDoc = wdApp.Documents.Add(strFile)
Call wdApp.Run("hideone")
End Sub
Sub wordhideone()
' hideone Macro
'
ActiveDocument.Bookmarks("one").Range.Font.Hidden = True
ActiveDocument.Bookmarks("one_01").Range.Font.Hidden = True
End Sub
Thank you for your help and I hope you are having a good day.
ASKER
Rgonzo1971,
Just tried your recommendation. The word document is still showing and the save as box still opens up. Thank you for your suggestion, if you have any additional thought I'd very much like to read them.
Thank you :).
Just tried your recommendation. The word document is still showing and the save as box still opens up. Thank you for your suggestion, if you have any additional thought I'd very much like to read them.
Thank you :).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Rgonzo,
That is perfect. This solves my issue. Below is the new codes being used for anyone who comes across this post.
in excel:
in word:
That is perfect. This solves my issue. Below is the new codes being used for anyone who comes across this post.
in excel:
Sub hideone1()
Dim wordApp As Object, newDoc As Object
Dim strFile As String
Dim myDoc As String
myDoc = "Risk Audit Report Template"
strFile = ThisWorkbook.Path & "\" & myDoc & ".docm"
'~> Establish an Word application object
On Error Resume Next
Set wdApp = GetObject("Word.Application")
If Err.Number <> 0 Then
Set wdApp = CreateObject("Word.Application")
End If
Err.Clear
On Error GoTo 0
'Make Risk Audit Report Template.docm. no visible, so it runs in back ground.
wdApp.Visible = False
'Final code to open Risk Audit Report Template.docm in the back ground.
Set newDoc = wdApp.Documents.Open(strFile)
'runs macro
Call wdApp.Run("hideone")
'save Risk Audit Report Template.docm.
newDoc.Save
'closes Risk Audit Report Template.docm.
newDoc.Close False
End Sub
in word:
Sub hideone()
'
ActiveDocument.Bookmarks("one").Range.Font.Hidden = True
ActiveDocument.Bookmarks("one_01").Range.Font.Hidden = True
End Sub
ASKER
Keep on keeping on. TY
pls try
Open in new window
Regards