Hello. I hope this is the right place for this question.
I have a Word macro that copies a table to a new Excel document.
That part is working fine. But once the item has been pasted, I want a message box to open IN EXCEL to tell the user what to do next.
So far, no matter what I do, the MsgBox only displays in Word, which is useless to me.
How can I specify that the MsgBox should be in EXCEL?
Code is below.
Code:Sub BackupTable() Selection.WholeStory Selection.Copy Dim Excel Set Excel = CreateObject("excel.application") Excel.Visible = True Set oWB = Excel.Workbooks.Add Set oWS = oWB.Worksheets(1) With oWS .Range("A1").Select oWS.Paste End With With oWS If .Range("A1") > 0 Then MsgBox "Please double-check that no images have been copied, and move on to the next step." End If End With End Sub
Last edited by yukimatsu; 10-29-2009 at 06:13 AM. Reason: code tags were missing
Hi yukimatsu
If you have a module in the word Document with the messagebox sub
export and import the module to the excel workbook then run the subCode:Option Explicit Sub CopyAModule(wkbFrom As String, _ wkbTo As String, _ strFromMod As String) Dim wkb As Workbook Dim strFile As String Set wkb = Workbooks(wkbFrom) strFile = wkb.Path & "\vbCode.bas" wkb.VBProject.VBComponents(strFromMod).Export strFile On Error Resume Next Set wkb = Workbooks(wkbTo) If Err.Number <> 0 Then Workbooks.Open wkbTo Set wkb = Workbooks(wkbTo) End If wkb.VBProject.VBComponents.Import strFile wkb.Save Set wkb = Nothing End Sub
regards pike
If the solution helped please donate here to the RSPCA
Sites worth visiting;
J&R Solutions - royUK
AJP Excel Information - Andy Pope
Spreadsheet Toolbox
JBeaucaires Excel Files
VBA for smarties - snb
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks