[SOLVED] Closing Notepad from Excel using VBA


"Excel VBA Help"

 

To stop seeing these ads and get other benefits check This page!
Automatic Translations (Powered by Powered by Google )
Catalan Chinese Croatian Czech Danish Dutch English Finnish French Galician German Greek Hindi Indonesian Italian Japanese Korean Latvian Lithuanian Norwegian Persian Polish Portuguese Romanian Serbian Slovak Slovenian Spanish Swedish Thai Turkish Ukrainian Vietnamese
Go Back   The Code Cage Forums > Microsoft Topics > Microsoft Excel Forum
Page showing the last 10:-
The Code Cage - Microsoft Office help


Microsoft Excel Forum Members Post questions in this forum if they are related to using Microsoft Excel, this includes Worksheet Functions, Excel VBA Programming, Simple Macro Code & Charting, Excel formula etc.

New Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 28th March 2012, 16:27
magnusflett's Avatar
Junior Member
MS Office Version: MS Office 2003
MS Office Skill Level: Can use VBA
 
Join Date: Mar 2012
Location: Ipswich, England
Age: 61
Posts: 3
My Top Tip Count: 0
Thanks to others: 0
Thanked 0 Times in 0 Posts
Chats: 0
Reputation: 10 (2) magnusflett is on a distinguished road
England
Post Closing Notepad from Excel using VBA
     Excel: VBA   


Can I close Notebook.exe from VBA?

I have a VBA program that writes calculated results to a text file. I can access this output file clicking a button and using the Shell command, typically:
VBA CODE:
Private Sub OutputLongButton_Click() 
    outputLongFile = "C:\RS01outputLongFile.txt" 
    RetVal = Shell("notepad.exe " & outputLongFile, vbNormalFocus) 
End Sub 
This works fine and notebook can be closed manually after viewing the file.

I also want to view the file whilst the calculation is halted using a YES/NO box. I can view the file with a similar routine to that above, but can I close notebook from VBA?

The file is displayed during the last part of my main calculation program:
VBA CODE:
outputLongFile = "C:\RS01outputLongFile.txt" 
RetVal = Shell("notepad.exe " & outputLongFile, vbMinimizedNoFocus) 
J = 0 'Reset time to zero
Call KeyboardInput 
If doAgainFlag = True Then Goto 200 
End Sub 
The Keyboard Input subroutine is the YES/NO box and is:
VBA CODE:
Sub KeyboardInput() 
    iReply = MsgBox(Prompt:="Do you wish to ammend the data using the keyboard?", _ 
    Buttons:=vbYesNo, Title:="Keyboard Input") 
    If iReply = vbYes Then 
        doAgainFlag = True 'Recalculate
        dataFlag = False 'Keyboard input
        Call ResetAll 'Reset for recalculation
    ElseIf iReply = vbNo Then 
        doAgainFlag = False 'Finished
        Exit Sub 
    End If 
End Sub 
Any suggestions?


Last edited by Leith Ross; 28th March 2012 at 17:04.
Reply & Quote Reply


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement
  #2 (permalink)  
Old 28th March 2012, 16:42
snb's Avatar
snb snb is offline
Forum VIP
MS Office Version: > Office 97
MS Office Skill Level: Interested
 
Join Date: Feb 2011
Location: Europe
Posts: 796
My Top Tip Count: 0
Thanks to others: 0
Thanked 174 Times in 171 Posts
Chats: 0
Reputation: 2977 (39) snb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond repute
Default Re: Closing Notepad from Excel using VBA

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.






Reply & Quote Reply


Did you find this post helpful? Yes | No
  #3 (permalink)  
Old 28th March 2012, 20:06
Leith Ross's Avatar
The Code Cage Staff
Solution Centre Professional
MS Office Version: 2000, 2003 & 2010
MS Office Skill Level: Expert in VBA
 
Join Date: Dec 2008
Location: San Bruno, CA USA
Age: 55
Posts: 375
My Top Tip Count: 0
Thanks to others: 1
Thanked 37 Times in 36 Posts
Chats: 0
Reputation: 694 (14) Leith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to behold
USA
Default Re: Closing Notepad from Excel using VBA

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.





__________________
Sincerely,
Leith Ross

Microsoft Office Help


Last edited by Leith Ross; 28th March 2012 at 20:08.
Reply & Quote Reply


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement
Global Live Casino

To stop seeing these ads and get other benefits check This page!

  #4 (permalink)  
Old 24th April 2012, 17:14
magnusflett's Avatar
Junior Member
MS Office Version: MS Office 2003
MS Office Skill Level: Can use VBA
 
Join Date: Mar 2012
Location: Ipswich, England
Age: 61
Posts: 3
My Top Tip Count: 0
Thanks to others: 0
Thanked 0 Times in 0 Posts
Chats: 0
Reputation: 10 (2) magnusflett is on a distinguished road
England
Default Re: Closing Notepad from Excel using VBA

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.






Reply & Quote Reply


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement
Global Live Casino

To stop seeing these ads and get other benefits check This page!

New Reply
The Code Cage at Facebookhe Code Cage at Twitter


Tags
closing, excel, notepad, vba

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


The Code Cage Affilliates


To stop seeing these ads and get other benefits check This page!


http://www.thecodecage.com/forumz tested by McAfee Security http://www.thecodecage.com/forumz tested by McAfee Security

All times are GMT +1. The time now is 16:44.


Translations supported by vBET 3.6.3
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
SEO by vBSEO
Template-Modifications by TMS
No part of this board, functionality or creatives may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
Copyright © Simon Lloyd 2008 - 2013
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application they represent and are used with permission from Microsoft
UA-8135493-1
Cultural Forum | Study at Malaysian University