Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2008

Tip: Looking for answers? Try searching our database.

How word is started

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred Kruger - 08 Jan 2008 19:32 GMT
I would like to know if it is posible to determine if how word has been
started.

I have been tiraling running word across a network when it normally starts
it loads a global template which carries all the sub routines needed to do
various things built into forms that are produced.

However other programs also use word as as a front end for doucuments they
contain within them, but because when the load word it takes an long time
because it is loading all the routines etc from the globally loaded template.

So here is what I would like to do if posible.

if word is opened by one of these other programs other than by the icon word
doesnt load the template if however its not opened.

I have used the following to determine if open by the icon

Sub iconstart()
'
'checks to see how word has been launched
'
Dim strCommandLine As String
     'get the commandline by calling the CmdLinetoString function, which
follows
     strCommandLine = CmdLinetoString(GetCommandLine())

     If Len(strCommandLine) <= Len(Chr(34) & Application.Path & _
       "\" & "winword.exe" & Chr(34) & " ") Then
         'Following only runs if Word was launched from its icon
           ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges 'closes
document without saving
     End If
 'End If
End Sub

Public Function CmdLinetoString(ByVal lngPtr As Long) As String
   Dim strReturn As String
   Dim StringLength As Long
   'get the length of the string (not including the terminating null
character)
   StringLength = lstrlen(lngPtr)
   'initialize our string so it has enough characters including the null
character
   strReturn = String$(StringLength + 1, 0)
   'copy the string we have a pointer to into our new string
   lstrcpy strReturn, lngPtr
   'now strip off the null character at the end
   strReturn = Left$(strReturn, StringLength)
   'return the string
   CmdLinetoString = strReturn
End Function

but is there a way of determining which program has opened word?????

I am using word 2003

Thanks in anticipation
Shauna Kelly - 09 Jan 2008 10:58 GMT
Hi Fred

As I understand it, you want a way to let other applications start Word
without loading your code, and you want users to start Word so that it
does load your code.

One way to do this might be as follows:

1. Create a .dot file that contains the code you want to load. Let's say
this is called "AllMyCode.dot". Store this in a known location, but not
in the Word Startup folder.

2. Create a second .dot file and put it in the Word startup folder. This
.dot file is called, say, "MyStartupFile.dot". It contains one macro
called, say "LoadMyStuff". This macro loads "AllMyCode.dot".

3. Change the shortcuts that users click to start Word by adding the
/mmacroname switch, eg winword.exe /mLoadMyStuff.

In all cases, MyStartupFile.dot will load, but it is tiny and will not
slow down the other apps that use Word. But when the user clicks the
shortcut, it will invoke the one macro in MyStartupFile.dot and it can
load your addin.

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

>I would like to know if it is posible to determine if how word has been
> started.
[quoted text clipped - 63 lines]
>
> Thanks in anticipation
Fred Kruger - 09 Jan 2008 21:06 GMT
Shauna

Thanks for this this was what I was looking for but dont undertand where in
the icon to put the switch as if I put it after the winword.exe in the icon
properties target i.e "C:\Program Files\Microsoft Office\Office\WINWORD.EXE"
(office97) it throws an error message up.

I cannot find where to put it in the office 11 icon.

Can you give me an idiots guide my startup.dot is called nichestart.dot
which has a sub routine called menuload in a module named general. I am
loading my menu from menuload as an add in template is this the best way?

Thanks for anticipation.

Fred

> Hi Fred
>
[quoted text clipped - 92 lines]
> >
> > Thanks in anticipation
Shauna Kelly - 12 Jan 2008 00:40 GMT
Hi Fred

You might need to create a shortcut explicitly and use that. One way to
do that is to right-click the desktop and choose New > Shortcut. Browse
to your winword.exe file. After you create the shortcut, right-click it
and choose its Properties, then change the target to something like"

"C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE"
/mNameOfMacroToRun

Note the position of quote marks and spaces carefully.

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

> Shauna
>
[quoted text clipped - 128 lines]
>> >
>> > Thanks in anticipation
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.