FYI: Open Word doc without unwanted messages

With the help of Doug Steele (thanks!) I was able to create a function to 
open Word docs more smoothly. Maybe it can be of use to someone else. See 
below for code and comments.

Lars


Function fOpenWordDoc(strFullPath As String)
On Error GoTo Err_Handler

'Purpose:   Open/BringToFront Word document without unwanted messages

'Comment:   This function either opens a Word document or,
'           if already opened by the user, brings it to front.
'           Bringing it to front and not re-opening the Word
'           document, prevents the default Word dialog
'           (open read only?, etc) to appear.
'           If the Word document is already opened by another
'           user, the user does get the default Word dialog
'           (open read only?, etc). Pressing 'Cancel' on this
'           dialog, won't result in a 'Command Failed' message.

'Argument:  strFullPath = the full path of the document

Dim oApp As Object
Dim objDoc As Object
Dim strFile As String
Dim booFound As Boolean

10  Set oApp = GetObject(Class:="Word.Application")
    'Get filename only (including the extension)
20  strFile = Mid(strFullPath, InStrRev(strFullPath, 1))
    'Check if document is already opened by user
30  For Each objDoc In oApp.Documents
40      If objDoc.Name = strFile Then
50          booFound = True
60          Exit For
70     End If
80  Next objDoc
90  If booFound = False Then
100     oApp.Documents.Open FileName:=strFullPath
110 End If

120  oApp.Visible = True
130  oApp.Activate
     'Bring the doc to front
140  oApp.WindowState = vbNormal
150  Set oApp = Nothing

Exit_Func: Exit Function
Err_Handler:
    Select Case Err.Number
         Case 429
            'Open Word as it is not opened yet
            Set oApp = CreateObject(Class:="Word.Application")
            Resume Next
         Case Else
            'Prevent 'Command failed' message if user wants to cancel
            'opening the doc because it is already opened by another user
            If Err.Number = 4198 And Erl = 100 Then
                Resume Exit_Func
            End If
            msgbox "Error " & Err.Number & ": " & _
                    Err.Description & " Line " & Erl
            Resume Exit_Func
    End Select
End Function 

0
Lars
1/30/2010 12:37:09 PM
access 16762 articles. 3 followers. Follow

0 Replies
764 Views

Similar Articles

[PageSpeed] 7

Reply:

Similar Artilces:

track message.....
I am using exchange 2003. My boss said that she sent me an e-mail last week. I say I did not receive. Is there a way to track that e-mail to see where it sent. We are all in the office under the same 2003 domain using outlook XP in the ESM, you can use the message tracking function... "Dooma" <Say-no-to-spam@hotmail.com> wrote in message news:OiwuZNpwEHA.2600@TK2MSFTNGP09.phx.gbl... > I am using exchange 2003. My boss said that she sent me an e-mail last week. > I say I did not receive. Is there a way to track that e-mail to see where it > sent. We are all in the...

Word as e-mail message editor
I upgraded from Outlook 2002 to Outlook 2003 on my XP system and now I am unable to select Word 2002 as my e- mail editor. The mail format option is looking for Word 2003 but it is not installed on my computer I'm stuck with the HTML option. As expected. Versions must match. You cannot use another version of Word if you want to use WordMail. -- Russ Valentine [MVP-Outlook] "AndyS" <anonymous@discussions.microsoft.com> wrote in message news:03d701c428c5$6da62590$3501280a@phx.gbl... > I upgraded from Outlook 2002 to Outlook 2003 on my XP > system and now I am unab...

Money 2000 Investment Transaction Error Message
I transferred shares in from another account to a new account. The amount, 3,200 shares, is correct and appears in the investment holdings schedule. I then sold the shares in three separate lots with the final sale 1,000 shares. The 1,000 shares appears correctly in the investment holdings schedule; however, when I enter sell 1,000 shares I get the error message, "The changes you are making will cause the share balance for "Security XYZ" to become negative at some point. Through trial and error I determined that it will permit me to sell 650 shares without the warning leaving a...

in excel when I open my workbook the file name is followed
the word [GROUP] when I try to sort the data in the spreadsheet I cannot -- I want to get rid of this [group] after the file name but can't figure out how to do it. Can you help? If you look down at the worksheet tabs you will see that two or more tabs are white in color. Note which ones are white. This means they are "grouped". To ungroup, select one and Right-click "ungroup" or just click on one not in the group. NOTE HERE: when sheets are grouped, what you do to one is done to all. If not sure how long you have had them grouped, I would suggest a careful ...

Merge & collate multipage doc
In Publisher 2002 I can't merge a multipage doc to collated/stapled output. Print merge seems to treat all resulting docs as one continuous doc. We just wanted to merge our staff newsletter to save the time of labelling each copy individually - how hard can it be? (Guess it's just too tricky for poor old Pub 2002.) Can anyone advise if this is the case - otherwise, how to fix it?? Much obliged - TC A small child turns to Ed, and exclaims: "Look! Look! A post from Tricky Carmel <trickycarmel@discussions.microsoft.com>!"... > In Publisher 2002 I can't merge...

Message times
I just sent a message to a customer at 09.04am. He acknowledged it by return to say thanks. Looking at the message it says I sent it at 08.04am! My PC has the right time (uk internet clock) and the customer is here in the UK too. Where is the error occuring? Thanks in advance, F Hi, My computer was doing the same thing yesterday, i check the clock time and zone on computer (which were all ok like yours) the only thing i did was before i turned it off last night, was click on the update now option under the internet time option, i dont know if this did it, but today its all fine again,...

Backup message: Unknown error
Hi there, I am trying to run a database backup from the Maintenance menu in GP 10.0. The module let me to create a backup schedule, but when I try to run an immediate backup it shows "Unknown error" message, and nothing happen. GP 10 version 1319 running under SQL 2008 SP2 and with all users logged out, it comes out the same error message. Same happens for system database. Thanks a lot for your directions. -- Gilberto Villegas IT Plus Inc. GP Business Solutions partner Gilberto, Are you trying to do the backup on the server physically or taking the same through Terminal S...

Outlook 2003 start new message with html source #2
Hi, I want to start a outlook message but write html to the source rather then text. Is this possible? I can open up an outlook 2003 message and write to the address, subject body. Example: C:\Program Files\Microsoft Office\Office11\Outlook.exe /c ipm.note /m asdf?subject=something^&body=^<b^>asdf^</b^> However, this writes <b>asdf</b> in the message body. I want it to write B (in bold), can this be done? Blast <Kyle.L.Watson@gmail.com> wrote: > Hi, I want to start a outlook message but write html to the source > rather then text. Is this possibl...

opening .xlsx and .docx files
I have clients using Office Pro 2007 and I cannot open their files with Office 2004 for mac.Will office 2008 open these files? Yes. The "x" files (.docx, .xlsx, etc.) are the native/default format for both Office 2007 (Windows) and for Office 2009 (Mac). Yes. So will office 2004 if you install this converter: http://www.microsoft.com/mac/downloads.mspx?pid=Mactopia_Office2004&fid=AB66 B5BF-37C3-41BB-945E-784782FC582C#viewer Cheers On 3/03/08 5:00 AM, in article ee8f684.-1@webcrossing.caR9absDaxw, "ardyn@officeformac.com" <ardyn@officeformac.com> wrote: >...

microsoft word 2003 save multipage doc to multiple files
Hello! Is there any possible way to resolve my problem : I have 60 page document and id like to split this doc to 60 single paged files. Is there any way to do this whit some magic word option? Reagrds - HE ...

DataBind Repeater to string[] in ViewData without code behind. MVC 2
Greetings, I'm coming from a WinForms background and diving into ASP.Net. I'm using: C#, VS2010, .Net 4.0, ASP.Net, MVC 2. What I want to do is get a string[] of roles in the controller with: string[] currentUsersRoles = Roles.GetRolesForUser(User.Identity.Name); Then I want to attach this to the ViewData object (also in the controller): ViewData["CurrentUsersRoles"] = currentUsersRoles; Now, in the View I want to bind a Repeater to the array I fed to ViewData. Something like: <asp:Repeater ID="CurrentUsersRoles" runat="se...

editing text in Word
Need help with figuring out memory problem. When trying to edit text in Word (class assignment), windows tells me it's low on memory, even with all programs closed. AFter reading the knowledge base, I tried to change the custom paging file, but I don't understand it. What should I enter in the maximum page file size? Valerie, I posted a response to this above, under the heading "Low on Memory." Sibyl On Fri, 26 Sep 2003 07:42:01 -0700, "Valerie" <valerie@nsatel.net> wrote: >Need help with figuring out memory problem. When trying >to edit text i...

rich text memo fields into word
Hi I'm using MS Access 2007 and MS Word 2003. In Access, I have created some Rich Text Memo fields. In Word, I have a template with some bookmarks. Now I want to fill up the content of the rich text memo fields into my Word template. But instead of expecting rich text formatting content, I just get ordinary HTML code like <div>my <b>bold text</b></div>.... What do I have to do to get the rich text formatted text into Word AS rich text formatted text ? kind regards Wolfgang Studer ...

Opening a Word file which was previously saved but is now too large
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) I have been working on a WORD document for several weeks, including images as well as text. I saved the doc as usual, but now when trying to open I get the message that WORD cannot now open the file because it is bigger than 32 megabytes. How can I recover this work? Any help appreciated! ...

Merging Docs and headers
I am using Windows 7. I have seven training documents that are completely separate Word documents and I want to merge them into one single Word document. I also want to change the headers for each of the 7 sections to reflect the subject matter. Kindly provide some assistance Create a next page break at the end of the first document. Press enter twice. Enter the header for the new section and make sure link to previous is off for all header types (different first, odd & even pages). Copy the break and one of the paragraph marks. Place the cursor on the last paragraph...

error message #102
OS is MS Windows XP Pro, Outlook is v2002, Photoshop is PS4. When using Adobe Photoshop 4 I get an error message exhorting me to make MS Oulook my default email client. I don't use Outlook for email...how can I prevent this message from appearing every time I open an item in PS4? David Hamer "David Hamer" <dhhamer@comcast.net> wrote in message news:L9ydnYi3c62as9zZnZ2dnUVZ_tCdnZ2d@comcast.com... > When using Adobe Photoshop 4 I get an error message exhorting me to make > MS Oulook my default email client. I don't use Outlook for email...how can > I &...

Can't open .pst files
I saved a lot of personal emails before I left my previous employer (large corp. thus did have a dedicated IT department). I had archived my emails many times in the past, but always used my work computer to open them, and never had a problem (.PST files). Now however, when I try to open my emails from home, I get the following error messages: When I try to copy or cut the file to my hard drive it says: "Error copying file or folder" "Cannot copy emails: the parameter is incorrect" When I try to open in Outlook: "File Access Denied, you do not have th...

How can I format a multi-sheet workbook from A4 to letter without.
I receive multi-sheet workbooks from our office overseas. They use A4 paper to print and I need to manually change each sheet to print it. Is there a quicker way? Like the old Global function in Lotus? Perhaps a macro? if you are changing entire sheets or the same amount/size of cells in every sheet, you can select those particualer cells, then hold down "ctrl" and click they sheets you want to format. if you are selecting, say, A1:F19 then you use my trick it will format those cells in all the selected sheets. "Catch101" wrote: > I receive multi-sheet workbooks...

Populating ActiveX Drop Down Menus in Word 2007
Can someone please help me with step-by-step instructions on how to populate an ActiveX drop down menu in word 2007 and also to be able to make the user's selection remain in the box when the document is closed and reopened, how can we program Word 2007 drop downs to function as such. Thanks a lot! Please send answers to: maneesh@tellasia.org Put the following in the ThisDocument item in the Microsoft Word Objects folder for the document in the Visual Basic Editor Private Sub ComboBox1_Change() ActiveDocument.Variables("varComboBox1").Value = ComboBox1.Value...

Error with Word as email editor using Outlook
when I reply to an email message I get a pop up that tells me that word is either busy or can't be found and that it will open instead with Outlook editor. I've turned on the word editor in my tools and options mail format tab but no luck. I've noticed also that the checked box to use word as editor does not stay checked. I've done all updates and still the problem persists. Any help? ...

MS Outlook+SP2+Office SP3= NG messages hanging-> HELP!
OK I hope this got someone's attention, cuss I need some help with this one. I just updated XP Pro to the SP2 and also while I was at it updated MS office to SP3 (separate patch) Now it seems when I'm in a news group and click on a posted message it hangs, and I finally get a message that no response from the server was given in 60 seconds and would I like to try again. But if I select a different message from a different poster, then it works...there seems to be no rhyme or reason to it. I also checked help and about on the Outlook Newsreader and it just has "About MS Ou...

Annoying Error message
Can anyone please help me. I have no idea what has caused this, but it has just suddenly started happening. I am running Outlook 2002 and every time I close outlook, I get this error on the top "Microsoft Visual C++ Runtime Library" and the error says "Runtime Error! Program: C:\Program Files\Microsoft Office\Office10 \OUTLOOK.EXE abnormal program termination" This happens every time I close outlook. It has only recently started happening and I have no idea what has caused it. What can I do to stop this?? Thanks Shaz ----- Shaz wrote: ---- ...

set default fill color upon open
I'm trying to find how to change the default fill color option on the toolbar and can't seem to get there.... Now I don't want to change the default template (XLSTART book.xlt) - Changing that just causes the NEW blank workbooks to have my modified yellow to gray scheme. But if someone emails me a spreadsheet the default when I open that session is still yellow. So what I'm asking is there a way via code in the workbook on open of the personal.xls file to set the default color in the fill option to be the 25% grey color index 15??? -Steve Hi Steve, For a start: I'm in...

Multiple excel users can open the same file and edit at the same .
We are running Excel 2002 SP2. We recently moved to a Windows 2000 server and now we are running into the issue where Multiple users can open the same excel file and edit it at the same time without getting the file the 2nd time in Read Only mode. Go to Tools>Share Workbook & choose the setting to Allow changes by more than one user. The file must also be stored in a Shared network/workgroup folder. Save the fil. It is also strongly recommended that you research the feature in Excel Help to become more familiar with it before you start sharing the file. HTH |:>) "Jef...

Rule for outgoing new messages
How do I create a rule to move all my outgoing messages to a specific domain to a specified folder? Example: All e-mails that I send to anyrecepient@photocontractor.com should be moved to the "photocontractor" folder. Wilfred <wpla@hotmail.com> wrote: > How do I create a rule to move all my outgoing messages to a specific > domain to a specified folder? > > Example: All e-mails that I send to anyrecepient@photocontractor.com > should be moved to the "photocontractor" folder. Use the "with specific words in the recipient's address" c...