Opening a selected file in Word from MFC app

Hi all,

I've a simple app in which the user can select a file from a list. Then
I want to open that file, using Word (as it's a Word document). Nothing
too scary, but it's got me stumped.

I've tried various samples & examples (automation et al) but have got
nowhere.

It seems to me that if I can simulate the behaviour of the "Run" box
(from the Start-> prompt) then I should be able to just throw the file
name at it (similar to double-clicking in Explorer) and all will be
well.

However, nothing works so far.

Has anyone out there any advice for me (aside from "it's a nice day so
go home") on how to get this running?

Thanks

Paul.

0
paul.ganney1 (118)
5/26/2005 4:48:20 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
490 Views

Similar Articles

[PageSpeed] 21

See if ShellExecute() works for you.

Paul S. Ganney wrote:
> Hi all,
>
> I've a simple app in which the user can select a file from a list. Then
> I want to open that file, using Word (as it's a Word document). Nothing
> too scary, but it's got me stumped.
>
> I've tried various samples & examples (automation et al) but have got
> nowhere.
>
> It seems to me that if I can simulate the behaviour of the "Run" box
> (from the Start-> prompt) then I should be able to just throw the file
> name at it (similar to double-clicking in Explorer) and all will be
> well.
>
> However, nothing works so far.
>
> Has anyone out there any advice for me (aside from "it's a nice day so
> go home") on how to get this running?
> 
> Thanks
> 
> Paul.

0
5/26/2005 4:54:42 PM
>It seems to me that if I can simulate the behaviour of the "Run" box
>(from the Start-> prompt) then I should be able to just throw the file
>name at it (similar to double-clicking in Explorer) and all will be
>well.

Paul,

I think you're looking for ShellExecuteEx.

Dave
0
davidl7375 (2060)
5/26/2005 4:56:26 PM
Thanks David and David - these were exactly what I was looking for.

Paul.

0
paul.ganney1 (118)
5/27/2005 9:56:53 AM
Reply:

Similar Artilces:

Open Puiblisher Document Without Program Installed
Is there a snap-in or some way to view a Publisher 2003 document without having the Publisher software installed? I know there is a viewer for Powerpoint slides and thought maybe there is something similiar for Publisher? I have done some searches and found nothing. Thanks in advance for any info. No, there isn't a Publisher viewer. Have your sender convert the publication to a PDF or a picture. There are free PDF converters around. You can download a trial version of Publisher 2007, when the trial runs out it will serve as a viewer. http://office.microsoft.com/en-us/publisher/FX...

File Not Found #2
I have a spreadsheet that is linked to over 100 other spreadsheets. Currently, a number of the linked spreadsheets are not saved on my computer. Every time I open the main spreadsheet, I get a hundred popups that say "cannot find file xxx.xls". Is there a way to open up the main file and avoid all these popups. in the workbook_open put in on error resume next i think that will work. >-----Original Message----- >I have a spreadsheet that is linked to over 100 other >spreadsheets. Currently, a number of the linked >spreadsheets are not saved on my computer. ...

Excel Crashes when trying to open a User Form
When I open the workbook and click on the worksheet to open the user form excels stops working. I get Microsoft Office Excel has stopped working and is trying find a solution, but it never does. I have saved it in both 2007 & 2003 versions and both get the same problem. What is odd is if you open the Userform Workbook, then open the VBA code window, both userform versions run fine, but if you do not open the Code window Excel locks up everytime. Here is the code. Sheet 2 Code: Private Sub Worksheet_SelectionChange(ByVal Target As Range) UserForm1.Show End Sub ...

Open previously opened serialized file != new open serialize file
Doing some testing of my reworked serialize code this morning (thanks for the help Sigurd and Headache - it fixed the pointer problems) and ran into something I don't understand. If I open a previously unopened (in the session) serialized file everything works fine. But if I close the file and reopen it, some of the pointers are undefined and the session crashes. Looking in the debugger, it does go through the ::Serialize code the second time, but clearly isn't actually reading it from disk since the pointer values have changed (from reasonable to cdcdcdcd). I assume the sessio...

Locked out of my 2004 file due to Passport requirement!
Just installed Money Deluxe 2005, big mistake. The unfortunate part is that I have already given away my 2004 version - I figured since I had my backup files it was no big deal. Well, while using 2004 I opted to NOT use Passport due to security reasons, I simply used the "Skip Login" button at the bottom. Now that I've installed 2005 I can't even get into my '04 file because there was no Passport account associated with it. I have no problem creating a new file, but I CANNOT for the life of me access my '04 file. I even tried re-installing the 2004 trial ve...

Textbox value automatically selected, How?
This has to be a simple one. When opening a userform I would like the value stored in the firs textbox to be selected. Therefore I can just start typing over th current value. Currently I have to click and drag the mouse over th old value to select it -- Message posted from http://www.ExcelForum.com Kevlar Try Private Sub UserForm_Activate() Me.TextBox1.SelStart = 0 Me.TextBox1.SelLength = Len(Me.TextBox1) End Su -- Message posted from http://www.ExcelForum.com That works well. Thanks Now, how do I get the list of choices in a listbox to default to th top ite -- Message posted from...

Aaarrgh! Why doesn't Office print my .eps files correctly
Please someone steer me in the right direction! I have a G4 mac with most graphics programs installed. Quark Xpress,=20 Freehand, Illustrator & Photoshop and all are OS X run. They all print = my=20 ..eps file perfectly. The Office package including both Excel and Word = can't=20 handle the file. Looks great on the screen, but printing is dreadful. Thanks in advance - would really appreciate some feedback. Nick From my experience Office doesn't support EPS files, you have to use TIF files. HTH. -- Ryan On 6/20/04 11:46 PM, in article 1f16201c4575b$7d925900$a501280a@phx.gbl,...

changes in MFC Source "COleDataSource::DelayRenderFileData()" from VC6 to VC7
Hi, I am a newbie to OLE, we have a product developed in VC++6.0.This has been recompiled in .net Visual Studio 2003. The compilation is fine but some of te functionality like drag & drop doen't work. Debugging the code revealed that the change in the MFC source has proven to be the culprit. If you look at the implementation of COleDataSource::DelayRenderFileData() implementation the line of code, "lpFormatEtc->tymed |= TYMED_ISTREAM|TYMED_HGLOBAL;" has been changed to "lpFormatEtc->tymed = TYMED_ISTREAM|TYMED_HGLOBAL;" because of this the form...

Query field select
I have a query that I use to run one of my reports. What I want to be able to do is select which fields I want printed on my report. If I was to create a form with checkboxes for each of my fields could I use that method to select which fields I wanted on my report? The user would then check which fields they want from the form and then click the command button to run the report with those chosen fields. Would this be possible? Also, I would want the users to select which field the report would be sorted by. What's the easiest approach to this? Try this on a couple of fields -- Use...

MFC: adding a control into a dialog window
void ChelloDlg::OnBnClickedEnable() { CWnd *parentWnd = GetDlgItem(IDD_HELLO_DIALOG); CStatic * newlabel = new CStatic(); newlabel->Create(_T("Hello World"), WS_CHILD | WS_VISIBLE, CRect(10, 10, 100, 100), parentWnd); } I am using a button ID_ENABLE to trigger the adding of label into IDD_HELLO_DIALOG. The program would crash ("Debug Assertion Failed") when I hit the button. What am I missing? -- @~@ Might, Courage, Vision, SINCERITY. / v \ Simplicity is Beauty! May the Force and Farce be with you! /( _ )\ (Xubuntu 8.04.1...

Customizing the Title bar of a Dialog box in MFC
Hi all, i have a dialog box , i have removed the system menu property from the dialog box so that, i will not have any system menu or close button on the dialog box. But now i want to have a icon of my own to be displayed on the dialog box, how do i customize the title bar to display my own icon. Thanx in advance <babagoudg@hcl.in> wrote in message news:1175670039.834588.212570@y66g2000hsf.googlegroups.com... > Hi all, > i have a dialog box , i have removed the system menu property from the > dialog box so that, i will not have any system menu or close button on > the dia...

Money has detected that I don't close the file before exiting....
I entered my password in my Money file, but I returned it me the following message : [Money has detected that you did not close the file "My Money" before exiting.Money now needs to verify the information in your.If your file is a large, this may take a few minutes.Do you want to do this now?If you click No,you'll need to open a different Money file.] Than I click Yes, but I returned it me the following message: [The password you entered was incorrect.Please try again.You may have made a typing error or typed the password for a different file] What I must do? I have ...

Add a list of words in a senders name to rule?
I would like to create a "cleanup" rule to run periodically. I would like to be able to put a list of domain names in a list, then have a rule where if any of those domain names are in the sender name they will be moved into the deleted folder. I get a lot of mail that I don't want to filter, but don' necessarily read everday either, and it mounts up. So, it would be nice if once ever couple of months I could go in,run the cleanup rule and clear the old ones out. -Jim You can do this by creating a rule that looks for "specific words in the sender's address"...

Log file sequence numbers
I am getting the warning saying I am about to run out of log file sequence numbering (ID 514). The stores are still up and running. Can I dismount the stores, and move the logs to a new location? Will that reset the numbering? Exchange 2003 SP2. Thank you. Ed On Wed, 28 Mar 2007 14:15:38 -0400, "Ed" <ed.jackson@americantower.com> wrote: >I am getting the warning saying I am about to run out of log file sequence >numbering (ID 514). The stores are still up and running. Can I dismount the >stores, and move the logs to a new location? Will that reset the numberin...

Print report which matches current record on open form
Hi, I have placed a button on my form which automatically prints a report based on the table I am using on the form. I would like the report to match the current record only. So if I fill out the form and hit the Print button it will print a report for only the current record - in other words, matched to the "Requisition Number" field. Thanks, Connie On Sat, 30 Jun 2007 18:27:37 GMT, Connie wrote: > Hi, > > I have placed a button on my form which automatically prints a report based > on the table I am using on the form. > > I would like the report to ma...

Bloated OST file: 19GB
I have a user with a 19.0 GB .OST Outlook says his mailbox is around 1.0GB, which matches what the Exchange server says (or thereabouts). I renamed and recreated his .OST a month ago, and once before that as well. The problem keeps coming back. This is the third time this user has experienced this error. This is an Exchange 2003 environment. This user has Vista SP1 and Office 2007 SP1. He is set up to auto-archive every 14 days anything older than 4 months ago. The user is also using Cached Exchange Mode. He does not use RSS feeds. I have other users with this error as well, and so ...

excel 2002
Hi folks, Have a bit of a problem. My company has a daily report using excel where we copy/paste info from an external source into it. when we were using 97, the growth of the file was fine(would go from a 1meg file to a 1.5meg file most times), but now that we're using the 2002 version, the files sizes are getting pretty silly(again from a 1meg file up to a 3-3.5 meg file.) After some testing, it is because of the four worksheets we paste into. We paste into it, run a macro to move that info into the places we want it, then clear the page....yet those pages are retaining the inf...

Selecting only one list item from ListView
I have a listView in MDI Application , .... By default multiple list items can be selected . How do I make it to select only one list item at a time ? On Mon, 14 Jul 2008 23:19:58 -0700 (PDT), "njoycoding@gmail.com" <njoycoding@gmail.com> wrote: >I have a listView in MDI Application , .... >By default multiple list items can be selected . >How do I make it to select only one list item at a time ? You need to specify the LVS_SINGLESEL style, probably in PreCreateWindow, e.g. BOOL MyListView::PreCreateWindow(CREATESTRUCT& cs) { cs.style |= LVS_REPORT | LVS_SI...

publisher/word templates
I use Publisher to create a Newsletter. As my responsibility and coverage area increases, I have to get the Newsletter to more sites. Most people do not have Publisher on their PCs. Is there a location on Microsofts website that has the same templetes for Publisher, but in Word format. kl wrote: > I use Publisher to create a Newsletter. As my > responsibility and coverage area increases, I have to get > the Newsletter to more sites. Most people do not have > Publisher on their PCs. Is there a location on Microsofts > website that has the same templetes for Publishe...

Trouble opening shared workbook
Hi there! I have an shared workbook which I have trouble opening. I=20 get an error message which says "Excel.exe has generated=20 an error." Then excel shuts down. I use Excel 2000. Others can open the workbook and I can open it on another=20 computer and I have tried to re-install office, it didn=B4t=20 help. The workbook is 3,5 mb. I can open it when co- workers remove the Shared property. Any help would be really nice /Pat ...

change a word file back to a pdf file
i changed a pdf file in to a word file how can i change it back to a pdf file in microsoft outlook. Also i could not read the file in word Please Help You post Word, PDF question in Outlook group? "Ann" <Ann@discussions.microsoft.com> wrote in message news:0A6AFC3C-2780-4182-BAFC-C07D3D9A7FF3@microsoft.com... >i changed a pdf file in to a word file how can i change it back to a pdf >file > in microsoft outlook. > > Also i could not read the file in word > Please Help Did you change it by simply renaming the file extension? -- Kathleen Orland - MVP...

checking to see if an mdb file is currently open
Is there a way to that VBA can check to see if another mde file (myApp.mde) is currently running in the client computer, and return TRUE if it is? Thanks in advance, Paul I should also have added that I'd also like VBA to make that file, myApp.mde, the current Window. > Is there a way to that VBA can check to see if another mde file > (myApp.mde) is currently running in the client computer, and return TRUE > if it is? > > Thanks in advance, > > Paul > ...

How can I convert a Publisher 97 file to Publisher 2000 so I can o
I need to open a Publisher 97 file from a disk with my Publisher 2000 Deluxe edition. Pub 2000 says it can't open previous versions. Any ideas? Disable your anti-virus software and try again. If you have Norton, disable "script blocking" and in Norton options, misc. clear "Office Plug-in." -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Picbro Okajun" <Picbro Okajun@discussions.microsoft.com> wrote in message news:E19BDCCA-4245-468C-A3F8-37C63FB5AA0F@microsoft.com... >I need to open a Pu...

I'm developing Custom POS button to process open Work Order using
This button should do some custom functionality like sending some data to payment processor (it's already implemented) after this order should be mark as Closed, Inventory should be updated etc. The problem is that I cannot find any mention of how to finalize the order (for some reasons Transaction.Post doesn't work). It's a code that I currently use. What else can I do to meet my purpose? int setDepositResult = Convert.ToInt32(transactionComType.InvokeMember("SetDepositTotal",BindingFlags.InvokeMethod, null,transaction,new object[1] {Convert.ToDecimal(tot...

Accessing Money 2001 files w/Money 2005
I have been using Money 2001 for, well, about 4 yrs. Thought it was time to upgrade and bought Money 2005. I can't access my M2001 backup file with M2005. I've gone through tech support and they couldn't help me. Anyone here have any suggestions? Besides trying to take the software back to the store. In microsoft.public.money, frustrated in WA wrote: >I have been using Money 2001 for, well, about 4 yrs. >Thought it was time to upgrade and bought Money 2005. I >can't access my M2001 backup file with M2005. I've gone >through tech support and they couldn...