<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Msgbox in Excel in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048210#M53700</link>
    <description>"wouldn't the code for the msgbox need to reside somewhere within the workbook "

Notice the comment, "'add this function to xl" above the function. You could add it to a specific xls, use vbe to add it to the xls, or create an xla so that it is always available.

-- 
----
Ed
----
  "Matt W" &lt;NOSPAM&gt; wrote in message news:40bf1845_2@newsprd01...
  Hi Ed
  I tried your code but...  it displayed the msgbox inside of AutoCAD and not in Excel.  Here's what I used (after adding a reference to Excel).

  Option Explicit

  ' Application - Excel
  Public oExcel As Excel.Application
  Public oBook As Excel.Workbook
  Public oSheet As Excel.Worksheet

  Public Sub CreateExcel()
      Dim i As Integer
      Set oExcel = CreateObject("Excel.Application")
      Set oBook = oExcel.Workbooks.Add
      Set oSheet = oBook.Worksheets(1)
      
      oExcel.Visible = True
  End Sub

  Function PassMsg(sPrompt As String, _
                  Optional cButtons As VbMsgBoxStyle, _
                  Optional sTitle As String)
      MsgBox sPrompt, cButtons, sTitle
  End Function
  '
  'run this from acad
  Sub test()
      CreateExcel
      'first set xlApp an xl Application object
      oExcel.Run PassMsg("This is a test", vbCritical, "Testing")
  End Sub

  I think (if I understand Joe correctly, and maybe he can step in and verify) what he wants is the msgbox to be shown in Excel.
  If that's the case, wouldn't the code for the msgbox need to reside somewhere within the workbook or a worksheet, then you can call that sub from AutoCAD, right?

  -- 
  Matt W
   
  There are 3 kinds of people:
    Those who can count, and those who can't.

    "Ed Jobe" &lt;EDLJOBE&gt; wrote in message news:40be4081$1_2@newsprd01...
    Matt, you can. Create a wrapper function in xl and use the app's Run method.

    'add this function to xl
    Function PassMsg(sPrompt As String, _
                    Optional cButtons As VbMsgBoxStyle, _
                    Optional sTitle As String)
        MsgBox sPrompt, cButtons, sTitle
    End Function
    '
    'run this from acad
    Sub test()
        'first set xlApp an xl Application object
        xlApp.Run PassMsg("This is a test", vbCritical, "Testing")
    End Sub

    -- 
    ----
    Ed
    ----
      "Matt W" &lt;NOSPAM&gt; wrote in message news:40be39fb_1@newsprd01...
      Given my experience with AutoCAD VBA and Excel, I don't think you can, but
      what you *can* do is have ACAD VBA display a msgbox, then switch focus to
      Excel.

      What exactly are you looking to do??


      -- 
      Matt W

      There are 3 kinds of people:
        Those who can count, and those who can't.


      "JoeMagas" &lt;NOSPAM&gt; wrote in message
      news:23683704.1086206811347.JavaMail.jive@jiveforum2.autodesk.com...
      | I would like an AutoCAD VBA program to display a MSGBOX in an opened
      session of excel, how can you do that?
      |
      | Joe&lt;/NOSPAM&gt;&lt;/NOSPAM&gt;&lt;/EDLJOBE&gt;&lt;/NOSPAM&gt;</description>
    <pubDate>Thu, 03 Jun 2004 14:26:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2004-06-03T14:26:03Z</dc:date>
    <item>
      <title>Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048204#M53694</link>
      <description>I would like an AutoCAD VBA program to display a MSGBOX in an opened session of excel, how can you do that?&lt;BR /&gt;
&lt;BR /&gt;
Joe</description>
      <pubDate>Wed, 02 Jun 2004 20:06:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048204#M53694</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-02T20:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048205#M53695</link>
      <description>Given my experience with AutoCAD VBA and Excel, I don't think you can, but
what you *can* do is have ACAD VBA display a msgbox, then switch focus to
Excel.

What exactly are you looking to do??


-- 
Matt W

There are 3 kinds of people:
  Those who can count, and those who can't.


"JoeMagas" &lt;NOSPAM&gt; wrote in message
news:23683704.1086206811347.JavaMail.jive@jiveforum2.autodesk.com...
| I would like an AutoCAD VBA program to display a MSGBOX in an opened
session of excel, how can you do that?
|
| Joe&lt;/NOSPAM&gt;</description>
      <pubDate>Wed, 02 Jun 2004 20:35:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048205#M53695</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-02T20:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048206#M53696</link>
      <description>I have a block counting program that export values to excel, I need a msgbox as a reminder to fill in the appropriate information.&lt;BR /&gt;
&lt;BR /&gt;
Do you have some code on changing focus?&lt;BR /&gt;
&lt;BR /&gt;
Joe</description>
      <pubDate>Wed, 02 Jun 2004 21:02:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048206#M53696</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-02T21:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048207#M53697</link>
      <description>Matt, you can. Create a wrapper function in xl and use the app's Run method.

'add this function to xl
Function PassMsg(sPrompt As String, _
                Optional cButtons As VbMsgBoxStyle, _
                Optional sTitle As String)
    MsgBox sPrompt, cButtons, sTitle
End Function
'
'run this from acad
Sub test()
    'first set xlApp an xl Application object
    xlApp.Run PassMsg("This is a test", vbCritical, "Testing")
End Sub

-- 
----
Ed
----
  "Matt W" &lt;NOSPAM&gt; wrote in message news:40be39fb_1@newsprd01...
  Given my experience with AutoCAD VBA and Excel, I don't think you can, but
  what you *can* do is have ACAD VBA display a msgbox, then switch focus to
  Excel.

  What exactly are you looking to do??


  -- 
  Matt W

  There are 3 kinds of people:
    Those who can count, and those who can't.


  "JoeMagas" &lt;NOSPAM&gt; wrote in message
  news:23683704.1086206811347.JavaMail.jive@jiveforum2.autodesk.com...
  | I would like an AutoCAD VBA program to display a MSGBOX in an opened
  session of excel, how can you do that?
  |
  | Joe&lt;/NOSPAM&gt;&lt;/NOSPAM&gt;</description>
      <pubDate>Wed, 02 Jun 2004 21:02:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048207#M53697</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-02T21:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048208#M53698</link>
      <description>Hi Ed
I tried your code but...  it displayed the msgbox inside of AutoCAD and not in Excel.  Here's what I used (after adding a reference to Excel).

Option Explicit

' Application - Excel
Public oExcel As Excel.Application
Public oBook As Excel.Workbook
Public oSheet As Excel.Worksheet

Public Sub CreateExcel()
    Dim i As Integer
    Set oExcel = CreateObject("Excel.Application")
    Set oBook = oExcel.Workbooks.Add
    Set oSheet = oBook.Worksheets(1)
    
    oExcel.Visible = True
End Sub

Function PassMsg(sPrompt As String, _
                Optional cButtons As VbMsgBoxStyle, _
                Optional sTitle As String)
    MsgBox sPrompt, cButtons, sTitle
End Function
'
'run this from acad
Sub test()
    CreateExcel
    'first set xlApp an xl Application object
    oExcel.Run PassMsg("This is a test", vbCritical, "Testing")
End Sub

I think (if I understand Joe correctly, and maybe he can step in and verify) what he wants is the msgbox to be shown in Excel.
If that's the case, wouldn't the code for the msgbox need to reside somewhere within the workbook or a worksheet, then you can call that sub from AutoCAD, right?

-- 
Matt W
 
There are 3 kinds of people:
  Those who can count, and those who can't.

  "Ed Jobe" &lt;EDLJOBE&gt; wrote in message news:40be4081$1_2@newsprd01...
  Matt, you can. Create a wrapper function in xl and use the app's Run method.

  'add this function to xl
  Function PassMsg(sPrompt As String, _
                  Optional cButtons As VbMsgBoxStyle, _
                  Optional sTitle As String)
      MsgBox sPrompt, cButtons, sTitle
  End Function
  '
  'run this from acad
  Sub test()
      'first set xlApp an xl Application object
      xlApp.Run PassMsg("This is a test", vbCritical, "Testing")
  End Sub

  -- 
  ----
  Ed
  ----
    "Matt W" &lt;NOSPAM&gt; wrote in message news:40be39fb_1@newsprd01...
    Given my experience with AutoCAD VBA and Excel, I don't think you can, but
    what you *can* do is have ACAD VBA display a msgbox, then switch focus to
    Excel.

    What exactly are you looking to do??


    -- 
    Matt W

    There are 3 kinds of people:
      Those who can count, and those who can't.


    "JoeMagas" &lt;NOSPAM&gt; wrote in message
    news:23683704.1086206811347.JavaMail.jive@jiveforum2.autodesk.com...
    | I would like an AutoCAD VBA program to display a MSGBOX in an opened
    session of excel, how can you do that?
    |
    | Joe&lt;/NOSPAM&gt;&lt;/NOSPAM&gt;&lt;/EDLJOBE&gt;</description>
      <pubDate>Thu, 03 Jun 2004 12:23:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048208#M53698</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-03T12:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048209#M53699</link>
      <description>That's what Ed shows.
&lt;CLIP&gt;
  'add this function to __xl__ [emphasis mine]
  Function PassMsg(sPrompt As String, _
&lt;/CLIP&gt;

;^)

-- 
R. Robert Bell


"Matt W" &lt;NOSPAM&gt; wrote in message
news:40bf1845_2@newsprd01...
Hi Ed
I tried your code but...  it displayed the msgbox inside of AutoCAD and not
in Excel.  Here's what I used (after adding a reference to Excel).

Option Explicit

' Application - Excel
Public oExcel As Excel.Application
Public oBook As Excel.Workbook
Public oSheet As Excel.Worksheet

Public Sub CreateExcel()
    Dim i As Integer
    Set oExcel = CreateObject("Excel.Application")
    Set oBook = oExcel.Workbooks.Add
    Set oSheet = oBook.Worksheets(1)

    oExcel.Visible = True
End Sub

Function PassMsg(sPrompt As String, _
                Optional cButtons As VbMsgBoxStyle, _
                Optional sTitle As String)
    MsgBox sPrompt, cButtons, sTitle
End Function
'
'run this from acad
Sub test()
    CreateExcel
    'first set xlApp an xl Application object
    oExcel.Run PassMsg("This is a test", vbCritical, "Testing")
End Sub

I think (if I understand Joe correctly, and maybe he can step in and verify)
what he wants is the msgbox to be shown in Excel.
If that's the case, wouldn't the code for the msgbox need to reside
somewhere within the workbook or a worksheet, then you can call that sub
from AutoCAD, right?

-- 
Matt W

There are 3 kinds of people:
  Those who can count, and those who can't.

  "Ed Jobe" &lt;EDLJOBE&gt; wrote in message
news:40be4081$1_2@newsprd01...
  Matt, you can. Create a wrapper function in xl and use the app's Run
method.

  'add this function to xl
  Function PassMsg(sPrompt As String, _
                  Optional cButtons As VbMsgBoxStyle, _
                  Optional sTitle As String)
      MsgBox sPrompt, cButtons, sTitle
  End Function
  '
  'run this from acad
  Sub test()
      'first set xlApp an xl Application object
      xlApp.Run PassMsg("This is a test", vbCritical, "Testing")
  End Sub

  -- 
  ----
  Ed
  ----
    "Matt W" &lt;NOSPAM&gt; wrote in message
news:40be39fb_1@newsprd01...
    Given my experience with AutoCAD VBA and Excel, I don't think you can,
but
    what you *can* do is have ACAD VBA display a msgbox, then switch focus
to
    Excel.

    What exactly are you looking to do??


    -- 
    Matt W

    There are 3 kinds of people:
      Those who can count, and those who can't.


    "JoeMagas" &lt;NOSPAM&gt; wrote in message
    news:23683704.1086206811347.JavaMail.jive@jiveforum2.autodesk.com...
    | I would like an AutoCAD VBA program to display a MSGBOX in an opened
    session of excel, how can you do that?
    |
    | Joe&lt;/NOSPAM&gt;&lt;/NOSPAM&gt;&lt;/EDLJOBE&gt;&lt;/NOSPAM&gt;</description>
      <pubDate>Thu, 03 Jun 2004 14:22:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048209#M53699</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-03T14:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048210#M53700</link>
      <description>"wouldn't the code for the msgbox need to reside somewhere within the workbook "

Notice the comment, "'add this function to xl" above the function. You could add it to a specific xls, use vbe to add it to the xls, or create an xla so that it is always available.

-- 
----
Ed
----
  "Matt W" &lt;NOSPAM&gt; wrote in message news:40bf1845_2@newsprd01...
  Hi Ed
  I tried your code but...  it displayed the msgbox inside of AutoCAD and not in Excel.  Here's what I used (after adding a reference to Excel).

  Option Explicit

  ' Application - Excel
  Public oExcel As Excel.Application
  Public oBook As Excel.Workbook
  Public oSheet As Excel.Worksheet

  Public Sub CreateExcel()
      Dim i As Integer
      Set oExcel = CreateObject("Excel.Application")
      Set oBook = oExcel.Workbooks.Add
      Set oSheet = oBook.Worksheets(1)
      
      oExcel.Visible = True
  End Sub

  Function PassMsg(sPrompt As String, _
                  Optional cButtons As VbMsgBoxStyle, _
                  Optional sTitle As String)
      MsgBox sPrompt, cButtons, sTitle
  End Function
  '
  'run this from acad
  Sub test()
      CreateExcel
      'first set xlApp an xl Application object
      oExcel.Run PassMsg("This is a test", vbCritical, "Testing")
  End Sub

  I think (if I understand Joe correctly, and maybe he can step in and verify) what he wants is the msgbox to be shown in Excel.
  If that's the case, wouldn't the code for the msgbox need to reside somewhere within the workbook or a worksheet, then you can call that sub from AutoCAD, right?

  -- 
  Matt W
   
  There are 3 kinds of people:
    Those who can count, and those who can't.

    "Ed Jobe" &lt;EDLJOBE&gt; wrote in message news:40be4081$1_2@newsprd01...
    Matt, you can. Create a wrapper function in xl and use the app's Run method.

    'add this function to xl
    Function PassMsg(sPrompt As String, _
                    Optional cButtons As VbMsgBoxStyle, _
                    Optional sTitle As String)
        MsgBox sPrompt, cButtons, sTitle
    End Function
    '
    'run this from acad
    Sub test()
        'first set xlApp an xl Application object
        xlApp.Run PassMsg("This is a test", vbCritical, "Testing")
    End Sub

    -- 
    ----
    Ed
    ----
      "Matt W" &lt;NOSPAM&gt; wrote in message news:40be39fb_1@newsprd01...
      Given my experience with AutoCAD VBA and Excel, I don't think you can, but
      what you *can* do is have ACAD VBA display a msgbox, then switch focus to
      Excel.

      What exactly are you looking to do??


      -- 
      Matt W

      There are 3 kinds of people:
        Those who can count, and those who can't.


      "JoeMagas" &lt;NOSPAM&gt; wrote in message
      news:23683704.1086206811347.JavaMail.jive@jiveforum2.autodesk.com...
      | I would like an AutoCAD VBA program to display a MSGBOX in an opened
      session of excel, how can you do that?
      |
      | Joe&lt;/NOSPAM&gt;&lt;/NOSPAM&gt;&lt;/EDLJOBE&gt;&lt;/NOSPAM&gt;</description>
      <pubDate>Thu, 03 Jun 2004 14:26:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048210#M53700</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-03T14:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048211#M53701</link>
      <description>Yes I would like Excel to display the dialog box (or at least appear that way)&lt;BR /&gt;
&lt;BR /&gt;
Once the user has exported the data he needs to be reminded to complete some sections of the excel document before sending out.&lt;BR /&gt;
&lt;BR /&gt;
Thanks all for your help,&lt;BR /&gt;
Joe</description>
      <pubDate>Thu, 03 Jun 2004 15:23:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048211#M53701</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-03T15:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048212#M53702</link>
      <description>Oh yeah... duh.
Well what do you expect... it wasn't even 8:30.
Sorry.


As for you Joe, here's what I would do:
1) Take the code that Ed wrote (modify it if need be) and put it into an
Excel workbook (this would be easier, in my opinion, than having AutoCAD
write the code to a module everytime).
2) Save that workbook as a template (*.XLT).
3) Have your ACAD VBA code open the template and write the block data to it.
4) Either save the workbook automatically or prompt the user for a location
to save it.

My 2 cents.

-- 
Matt W

There are 3 kinds of people:
  Those who can count, and those who can't.

"R. Robert Bell" &lt;NOT.ROBERTB&gt; wrote in message
news:40bf3432_3@newsprd01...
| That's what Ed shows.
| &lt;CLIP&gt;
|   'add this function to __xl__ [emphasis mine]
|   Function PassMsg(sPrompt As String, _
| &lt;/CLIP&gt;
|
| ;^)
|
| -- 
| R. Robert Bell
|
|
| "Matt W" &lt;NOSPAM&gt; wrote in message
| news:40bf1845_2@newsprd01...
| Hi Ed
| I tried your code but...  it displayed the msgbox inside of AutoCAD and
not
| in Excel.  Here's what I used (after adding a reference to Excel).
|
| Option Explicit
|
| ' Application - Excel
| Public oExcel As Excel.Application
| Public oBook As Excel.Workbook
| Public oSheet As Excel.Worksheet
|
| Public Sub CreateExcel()
|     Dim i As Integer
|     Set oExcel = CreateObject("Excel.Application")
|     Set oBook = oExcel.Workbooks.Add
|     Set oSheet = oBook.Worksheets(1)
|
|     oExcel.Visible = True
| End Sub
|
| Function PassMsg(sPrompt As String, _
|                 Optional cButtons As VbMsgBoxStyle, _
|                 Optional sTitle As String)
|     MsgBox sPrompt, cButtons, sTitle
| End Function
| '
| 'run this from acad
| Sub test()
|     CreateExcel
|     'first set xlApp an xl Application object
|     oExcel.Run PassMsg("This is a test", vbCritical, "Testing")
| End Sub
|
| I think (if I understand Joe correctly, and maybe he can step in and
verify)
| what he wants is the msgbox to be shown in Excel.
| If that's the case, wouldn't the code for the msgbox need to reside
| somewhere within the workbook or a worksheet, then you can call that sub
| from AutoCAD, right?
|
| -- 
| Matt W
|
| There are 3 kinds of people:
|   Those who can count, and those who can't.
|
|   "Ed Jobe" &lt;EDLJOBE&gt; wrote in message
| news:40be4081$1_2@newsprd01...
|   Matt, you can. Create a wrapper function in xl and use the app's Run
| method.
|
|   'add this function to xl
|   Function PassMsg(sPrompt As String, _
|                   Optional cButtons As VbMsgBoxStyle, _
|                   Optional sTitle As String)
|       MsgBox sPrompt, cButtons, sTitle
|   End Function
|   '
|   'run this from acad
|   Sub test()
|       'first set xlApp an xl Application object
|       xlApp.Run PassMsg("This is a test", vbCritical, "Testing")
|   End Sub
|
|   -- 
|   ----
|   Ed
|   ----
|     "Matt W" &lt;NOSPAM&gt; wrote in message
| news:40be39fb_1@newsprd01...
|     Given my experience with AutoCAD VBA and Excel, I don't think you can,
| but
|     what you *can* do is have ACAD VBA display a msgbox, then switch focus
| to
|     Excel.
|
|     What exactly are you looking to do??
|
|
|     -- 
|     Matt W
|
|     There are 3 kinds of people:
|       Those who can count, and those who can't.
|
|
|     "JoeMagas" &lt;NOSPAM&gt; wrote in message
|     news:23683704.1086206811347.JavaMail.jive@jiveforum2.autodesk.com...
|     | I would like an AutoCAD VBA program to display a MSGBOX in an opened
|     session of excel, how can you do that?
|     |
|     | Joe
|
|
|&lt;/NOSPAM&gt;&lt;/NOSPAM&gt;&lt;/EDLJOBE&gt;&lt;/NOSPAM&gt;&lt;/NOT.ROBERTB&gt;</description>
      <pubDate>Thu, 03 Jun 2004 18:09:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048212#M53702</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-03T18:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048213#M53703</link>
      <description>I would save it in an xla, addin file.
Start a new xls.
Add the macro to ThisWorkbook.
Save the file as an addin using the "Files of type" combo.
Save it to one of the XLSTART folders and it will auto load when xl starts and you won't need to add the code to every file.

-- 
----
Ed
----
  "Matt W" &lt;NOSPAM&gt; wrote in message news:40bf694e$1_2@newsprd01...
  Oh yeah... duh.
  Well what do you expect... it wasn't even 8:30.
  Sorry.


  As for you Joe, here's what I would do:
  1) Take the code that Ed wrote (modify it if need be) and put it into an
  Excel workbook (this would be easier, in my opinion, than having AutoCAD
  write the code to a module everytime).
  2) Save that workbook as a template (*.XLT).
  3) Have your ACAD VBA code open the template and write the block data to it.
  4) Either save the workbook automatically or prompt the user for a location
  to save it.

  My 2 cents.

  -- 
  Matt W

  There are 3 kinds of people:
    Those who can count, and those who can't.

  "R. Robert Bell" &lt;NOT.ROBERTB&gt; wrote in message
  news:40bf3432_3@newsprd01...
  | That's what Ed shows.
  | &lt;CLIP&gt;
  |   'add this function to __xl__ [emphasis mine]
  |   Function PassMsg(sPrompt As String, _
  | &lt;/CLIP&gt;
  |
  | ;^)
  |
  | -- 
  | R. Robert Bell
  |
  |
  | "Matt W" &lt;NOSPAM&gt; wrote in message
  | news:40bf1845_2@newsprd01...
  | Hi Ed
  | I tried your code but...  it displayed the msgbox inside of AutoCAD and
  not
  | in Excel.  Here's what I used (after adding a reference to Excel).
  |
  | Option Explicit
  |
  | ' Application - Excel
  | Public oExcel As Excel.Application
  | Public oBook As Excel.Workbook
  | Public oSheet As Excel.Worksheet
  |
  | Public Sub CreateExcel()
  |     Dim i As Integer
  |     Set oExcel = CreateObject("Excel.Application")
  |     Set oBook = oExcel.Workbooks.Add
  |     Set oSheet = oBook.Worksheets(1)
  |
  |     oExcel.Visible = True
  | End Sub
  |
  | Function PassMsg(sPrompt As String, _
  |                 Optional cButtons As VbMsgBoxStyle, _
  |                 Optional sTitle As String)
  |     MsgBox sPrompt, cButtons, sTitle
  | End Function
  | '
  | 'run this from acad
  | Sub test()
  |     CreateExcel
  |     'first set xlApp an xl Application object
  |     oExcel.Run PassMsg("This is a test", vbCritical, "Testing")
  | End Sub
  |
  | I think (if I understand Joe correctly, and maybe he can step in and
  verify)
  | what he wants is the msgbox to be shown in Excel.
  | If that's the case, wouldn't the code for the msgbox need to reside
  | somewhere within the workbook or a worksheet, then you can call that sub
  | from AutoCAD, right?
  |
  | -- 
  | Matt W
  |
  | There are 3 kinds of people:
  |   Those who can count, and those who can't.
  |
  |   "Ed Jobe" &lt;EDLJOBE&gt; wrote in message
  | news:40be4081$1_2@newsprd01...
  |   Matt, you can. Create a wrapper function in xl and use the app's Run
  | method.
  |
  |   'add this function to xl
  |   Function PassMsg(sPrompt As String, _
  |                   Optional cButtons As VbMsgBoxStyle, _
  |                   Optional sTitle As String)
  |       MsgBox sPrompt, cButtons, sTitle
  |   End Function
  |   '
  |   'run this from acad
  |   Sub test()
  |       'first set xlApp an xl Application object
  |       xlApp.Run PassMsg("This is a test", vbCritical, "Testing")
  |   End Sub
  |
  |   -- 
  |   ----
  |   Ed
  |   ----
  |     "Matt W" &lt;NOSPAM&gt; wrote in message
  | news:40be39fb_1@newsprd01...
  |     Given my experience with AutoCAD VBA and Excel, I don't think you can,
  | but
  |     what you *can* do is have ACAD VBA display a msgbox, then switch focus
  | to
  |     Excel.
  |
  |     What exactly are you looking to do??
  |
  |
  |     -- 
  |     Matt W
  |
  |     There are 3 kinds of people:
  |       Those who can count, and those who can't.
  |
  |
  |     "JoeMagas" &lt;NOSPAM&gt; wrote in message
  |     news:23683704.1086206811347.JavaMail.jive@jiveforum2.autodesk.com...
  |     | I would like an AutoCAD VBA program to display a MSGBOX in an opened
  |     session of excel, how can you do that?
  |     |
  |     | Joe
  |
  |
  |&lt;/NOSPAM&gt;&lt;/NOSPAM&gt;&lt;/EDLJOBE&gt;&lt;/NOSPAM&gt;&lt;/NOT.ROBERTB&gt;&lt;/NOSPAM&gt;</description>
      <pubDate>Thu, 03 Jun 2004 18:41:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048213#M53703</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-03T18:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048214#M53704</link>
      <description>An Add-In.
Hmmmmm....  I hadn't thougth of that.  I guess there *is* more than one way to skin the proverbial cat.


-- 
Matt W
 
There are 3 kinds of people:
  Those who can count, and those who can't.

  "Ed Jobe" &lt;EDLJOBE&gt; wrote in message news:40bf70ec$1_1@newsprd01...
  I would save it in an xla, addin file.
  Start a new xls.
  Add the macro to ThisWorkbook.
  Save the file as an addin using the "Files of type" combo.
  Save it to one of the XLSTART folders and it will auto load when xl starts and you won't need to add the code to every file.

  -- 
  ----
  Ed
  ----
    "Matt W" &lt;NOSPAM&gt; wrote in message news:40bf694e$1_2@newsprd01...
    Oh yeah... duh.
    Well what do you expect... it wasn't even 8:30.
    Sorry.


    As for you Joe, here's what I would do:
    1) Take the code that Ed wrote (modify it if need be) and put it into an
    Excel workbook (this would be easier, in my opinion, than having AutoCAD
    write the code to a module everytime).
    2) Save that workbook as a template (*.XLT).
    3) Have your ACAD VBA code open the template and write the block data to it.
    4) Either save the workbook automatically or prompt the user for a location
    to save it.

    My 2 cents.

    -- 
    Matt W

    There are 3 kinds of people:
      Those who can count, and those who can't.

    "R. Robert Bell" &lt;NOT.ROBERTB&gt; wrote in message
    news:40bf3432_3@newsprd01...
    | That's what Ed shows.
    | &lt;CLIP&gt;
    |   'add this function to __xl__ [emphasis mine]
    |   Function PassMsg(sPrompt As String, _
    | &lt;/CLIP&gt;
    |
    | ;^)
    |
    | -- 
    | R. Robert Bell
    |
    |
    | "Matt W" &lt;NOSPAM&gt; wrote in message
    | news:40bf1845_2@newsprd01...
    | Hi Ed
    | I tried your code but...  it displayed the msgbox inside of AutoCAD and
    not
    | in Excel.  Here's what I used (after adding a reference to Excel).
    |
    | Option Explicit
    |
    | ' Application - Excel
    | Public oExcel As Excel.Application
    | Public oBook As Excel.Workbook
    | Public oSheet As Excel.Worksheet
    |
    | Public Sub CreateExcel()
    |     Dim i As Integer
    |     Set oExcel = CreateObject("Excel.Application")
    |     Set oBook = oExcel.Workbooks.Add
    |     Set oSheet = oBook.Worksheets(1)
    |
    |     oExcel.Visible = True
    | End Sub
    |
    | Function PassMsg(sPrompt As String, _
    |                 Optional cButtons As VbMsgBoxStyle, _
    |                 Optional sTitle As String)
    |     MsgBox sPrompt, cButtons, sTitle
    | End Function
    | '
    | 'run this from acad
    | Sub test()
    |     CreateExcel
    |     'first set xlApp an xl Application object
    |     oExcel.Run PassMsg("This is a test", vbCritical, "Testing")
    | End Sub
    |
    | I think (if I understand Joe correctly, and maybe he can step in and
    verify)
    | what he wants is the msgbox to be shown in Excel.
    | If that's the case, wouldn't the code for the msgbox need to reside
    | somewhere within the workbook or a worksheet, then you can call that sub
    | from AutoCAD, right?
    |
    | -- 
    | Matt W
    |
    | There are 3 kinds of people:
    |   Those who can count, and those who can't.
    |
    |   "Ed Jobe" &lt;EDLJOBE&gt; wrote in message
    | news:40be4081$1_2@newsprd01...
    |   Matt, you can. Create a wrapper function in xl and use the app's Run
    | method.
    |
    |   'add this function to xl
    |   Function PassMsg(sPrompt As String, _
    |                   Optional cButtons As VbMsgBoxStyle, _
    |                   Optional sTitle As String)
    |       MsgBox sPrompt, cButtons, sTitle
    |   End Function
    |   '
    |   'run this from acad
    |   Sub test()
    |       'first set xlApp an xl Application object
    |       xlApp.Run PassMsg("This is a test", vbCritical, "Testing")
    |   End Sub
    |
    |   -- 
    |   ----
    |   Ed
    |   ----
    |     "Matt W" &lt;NOSPAM&gt; wrote in message
    | news:40be39fb_1@newsprd01...
    |     Given my experience with AutoCAD VBA and Excel, I don't think you can,
    | but
    |     what you *can* do is have ACAD VBA display a msgbox, then switch focus
    | to
    |     Excel.
    |
    |     What exactly are you looking to do??
    |
    |
    |     -- 
    |     Matt W
    |
    |     There are 3 kinds of people:
    |       Those who can count, and those who can't.
    |
    |
    |     "JoeMagas" &lt;NOSPAM&gt; wrote in message
    |     news:23683704.1086206811347.JavaMail.jive@jiveforum2.autodesk.com...
    |     | I would like an AutoCAD VBA program to display a MSGBOX in an opened
    |     session of excel, how can you do that?
    |     |
    |     | Joe
    |
    |
    |&lt;/NOSPAM&gt;&lt;/NOSPAM&gt;&lt;/EDLJOBE&gt;&lt;/NOSPAM&gt;&lt;/NOT.ROBERTB&gt;&lt;/NOSPAM&gt;&lt;/EDLJOBE&gt;</description>
      <pubDate>Thu, 03 Jun 2004 19:10:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048214#M53704</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-03T19:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048215#M53705</link>
      <description>Thanks everyone for your help with this:&lt;BR /&gt;
&lt;BR /&gt;
I am very close, but still having a bit of trouble.&lt;BR /&gt;
&lt;BR /&gt;
Here is my code:&lt;BR /&gt;
&lt;BR /&gt;
    Set objExcel = GetObject(, "Excel.application")&lt;BR /&gt;
    If Err &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;
        Err.Clear&lt;BR /&gt;
        Set objExcel = CreateObject("Excel.application")&lt;BR /&gt;
            If Err &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;
            MsgBox "Could not start Excel", vbExclamation&lt;BR /&gt;
            End&lt;BR /&gt;
        End If&lt;BR /&gt;
    End If&lt;BR /&gt;
    objExcel.Visible = True&lt;BR /&gt;
&lt;BR /&gt;
    Set wkbkobj = objExcel.Workbooks.Open(strFileName) 'opens a "template" file&lt;BR /&gt;
&lt;BR /&gt;
    objExcel.Run PassMsg("This is a test", vbCritical, "Testing")&lt;BR /&gt;
&lt;BR /&gt;
When I run the above I get this error message (in AutoCAD):&lt;BR /&gt;
&lt;BR /&gt;
Complile error:&lt;BR /&gt;
Sub or Function not defined.&lt;BR /&gt;
&lt;BR /&gt;
I suspect that I may be saving the function in Excel in the wrong place.&lt;BR /&gt;
&lt;BR /&gt;
Any ideas or suggestions:&lt;BR /&gt;
Joe</description>
      <pubDate>Mon, 07 Jun 2004 17:21:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048215#M53705</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-07T17:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048216#M53706</link>
      <description>You didn't say where you saved it.

-- 
----
Ed
----
  "JoeMagas" &lt;NOSPAM&gt; wrote in message news:2439981.1086628933162.JavaMail.jive@jiveforum2...
  Thanks everyone for your help with this:

  I am very close, but still having a bit of trouble.

  Here is my code:

      Set objExcel = GetObject(, "Excel.application")
      If Err &amp;lt;&amp;gt; 0 Then
          Err.Clear
          Set objExcel = CreateObject("Excel.application")
              If Err &amp;lt;&amp;gt; 0 Then
              MsgBox "Could not start Excel", vbExclamation
              End
          End If
      End If
      objExcel.Visible = True

      Set wkbkobj = objExcel.Workbooks.Open(strFileName) 'opens a "template" file

      objExcel.Run PassMsg("This is a test", vbCritical, "Testing")

  When I run the above I get this error message (in AutoCAD):

  Complile error:
  Sub or Function not defined.

  I suspect that I may be saving the function in Excel in the wrong place.

  Any ideas or suggestions:
  Joe&lt;/NOSPAM&gt;</description>
      <pubDate>Mon, 07 Jun 2004 17:35:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048216#M53706</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-07T17:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048217#M53707</link>
      <description>I saved it (in Excel VBA) under Microsoft Excel Objects in (General) in the Excel file that I load.&lt;BR /&gt;
&lt;BR /&gt;
Joe</description>
      <pubDate>Mon, 07 Jun 2004 17:56:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048217#M53707</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-07T17:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Msgbox in Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048218#M53708</link>
      <description>Joe, if you saved it in that xls, then it is only available in that xls. When you open a new xls from a template as your code shows, the macro is not there. You will either have to save it in the template or save it in an add-in. I reccommend using an add-in, because if you put it in a template, it will unnecissarily add it to every xls. See the other post I made to Matt.

-- 
----
Ed
----
  "JoeMagas" &lt;NOSPAM&gt; wrote in message news:28358160.1086631030435.JavaMail.jive@jiveforum2.autodesk.com...
  I saved it (in Excel VBA) under Microsoft Excel Objects in (General) in the Excel file that I load.

  Joe&lt;/NOSPAM&gt;</description>
      <pubDate>Mon, 07 Jun 2004 19:47:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/msgbox-in-excel/m-p/1048218#M53708</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-06-07T19:47:42Z</dc:date>
    </item>
  </channel>
</rss>

