+ Reply to Thread
Results 1 to 11 of 11

vba word(2003) codes to display message box in excel(2003)

  1. #1
    Registered User
    Join Date
    08-10-2012
    Location
    germany
    MS-Off Ver
    Excel 2003
    Posts
    34

    vba word(2003) codes to display message box in excel(2003)

    Hi guys,
    I have been working with VBA since a month and sometime struggle to find the right codes. Although i didnt take any kind of coaching in VBA, most of the solutions i find on the net and with a lot of trial and error, wasting time. I hope you'll will come to my rescue.
    I have created a word(2003) template which consists of some tables, the useres fill in the tables and then press a button on the template and then the following things happen:
    1) A new excel worksheet(2003) is created with the preset headings and format
    2) All the data filled by the users in the word template are exported to that newly created excel sheet.
    I want a message box that appears on the excel sheet (and not on the word template) that says "Please save the excel document with a new name!".
    Would be grateful if you'll could provide a VBA word (2003) code that displays the message box on the newly created excel 2003 sheet.

    Sam,

    Thanks in advance.

  2. #2
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: vba word(2003) codes to display message box in excel(2003)

    How about..

    Please Login or Register  to view this content.
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Registered User
    Join Date
    08-10-2012
    Location
    germany
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: vba word(2003) codes to display message box in excel(2003)

    I was trying to use the following codes, but they dont work. would be grateful if somebody could correct it.

    Please Login or Register  to view this content.
    Last edited by Cutter; 08-21-2012 at 07:48 PM. Reason: Corrected code tags

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: vba word(2003) codes to display message box in excel(2003)

    Hi Sam,

    Why, if you want the data in Excel, are you using Word for the data entry? Seems unnecessarily convoluted to me.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    Registered User
    Join Date
    08-10-2012
    Location
    germany
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: vba word(2003) codes to display message box in excel(2003)

    Hi Paul Edstein,
    The word template consists of tables where the users from different departments have to fill in the details of the meetings, agenda of the meeting and so on. All this data is collected in an Excel sheet, where it would be used for later validation. I want to make the usage of the word template as user friendly as possible.
    When the button on the word template is clicked, a new excel workbook is created and appears and the data is exported from word to the visible excel sheet. After the export is completed, i would like a message box to appear on the excel workbook saying "save this excel document with a new name!" (or it can be any other message).
    Currently the message box appears on the word template, which the users can see only when they minimise the newely created excel workbook.

    regards,

    Sam
    Last edited by samkumar; 08-21-2012 at 07:11 AM.

  6. #6
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: vba word(2003) codes to display message box in excel(2003)

    Hi Sam,

    Everything you've described so far can be done quite easily and entirely within Excel. Tables - You can have multiple logical tables on the same worksheet or have a separate worksheet for each table. Either way, it's far easier to acquire the data in Excel than to acquire it in Word then export to Excel.

  7. #7
    Registered User
    Join Date
    08-10-2012
    Location
    germany
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: vba word(2003) codes to display message box in excel(2003)

    Hi Paul Edstein,
    thanks for the advice. but i have spent too much time on the word template, would be happy if i could get the word template working.

    Regards,
    Sam

  8. #8
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: vba word(2003) codes to display message box in excel(2003)

    Hi Sam,

    OK, first off, there is no such thing as ExcelBasic.

    You could, however, add a macro to the new workbook and execute it, using code like:
    Please Login or Register  to view this content.
    It's a bit clunky - you can see the macro being written - but it works.

  9. #9
    Registered User
    Join Date
    08-10-2012
    Location
    germany
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: vba word(2003) codes to display message box in excel(2003)

    Hi marcopod,
    Thanks for the codes, i tested it, doesnt seem to work. When I run the code a new excel sheet is created and i see a small window for a split second and then it vanishes.

    thanks anyway,,

    Sam

  10. #10
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: vba word(2003) codes to display message box in excel(2003)

    It worked fine in my testing. One of the limitations of using Sendkeys is that the method is subject to timing issues that can cause the code to fail. You may get better results breaking it down into smaller chunks, like:
    SendKeys "%{F11}%IM", True
    SendKeys "Sub Demo(): MsgBox ""Hello"": End Sub", True
    SendKeys "%{F11}%{F8}{ENTER}", True

    I'll also reiterate the advice I gave before that you're making things unnecessarily complicated. SImply copying & pasting your Word tables into Excel would probably preserve most of the structure.

  11. #11
    Registered User
    Join Date
    08-10-2012
    Location
    germany
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: vba word(2003) codes to display message box in excel(2003)

    Hi marcopod,
    thanks a lot for the codes. I tested it but there are some minor faults, I will edit them and will recheck.
    thanks a lot for your time.

    Sam.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1