JingleRock
Wed Nov 08 00:16:02 CST 2006
Cindy,
Thanks for your post.
The reason I did not identify the error is because my weak error-trapping
for a "logged off" situation did not tell me. I have since added a
'SendErrorEmail' Sub that now indicates that it is Error No. 70 - "Permission
denied".
All of the Office 2003 Applications are installed on my machine.
Some background: I am on a large corporate network, but there are only 20
users for this business-day daily process. We are running Windows XP Pro
SP-2. One option is to run this process on an Autosys server; however, there
are several drawbacks: including administrative red-tape and the data files
that are updated daily sometimes need to be revised, perhaps two weeks after
the first data is reported. So, I am thinking about running this process on
my machine; one of the drawbacks is that frequently our LAN Admin pushes
software updates down to each of the workstations at night -- this re-boots
our machines. So, the idea is to write VBA code on my C: drive, containing
an 'Auto_Open' stmt that is triggered by a Windows XP Scheduled Task that is
scheduled to fire at a specified time on each business day. I want this code
to execute when my machine is "logged on" and when it is "logged off". The
VBA Projects are digitally signed by me. The VBA Code is in an .xlA file
stored on my C: drive; this file is not set-up as an 'AddIn' in EXCEL.
Other Code Changes: I am now Dimming objDoc As Document; I deleted
'objWord.Visible = False'; and I deleted 'objDoc.Activate'.
All below refers to my machine running "logged off":
I am currently focusing my experimentation on opening the .rtf data file,
making a few edits, and then saving it back to a shared network drive; I am
not currently referring whatsoever to my .xlS primary data file. My Code is
behaving better:
the Scheduled Task is completing its Task; the WINWORD file is not
"hanging"; and
I am receiving Error E-Mails indicating Error No. 70.
I think there is some problem having two instances of Office Applications
open at the same time (I am able, using WORD VBA [NO references to EXCEL],
open up the same .rtf file, make changes in it, and then save it back to the
shared network drive, all on a "logged off" basis). However, my EXCEL Code
is able to send me e-mails (using CDO and at least a portion of OUTLOOK) from
our SMTP Server, on a "logged off" basis.
"Cindy M." wrote:
> Since you don't tell us what the error is that's generated by running the line
> Set objWord = New Word.Application, it's difficult to even guess. It would also
> help to know what, exactly, is on the network and what is on your machine. Is
> Word even installed on your machine?
>
> > Below is my early binding code procedure:
> >
> > Public Sub Import_From_WORD_Tables()
> >
> > Dim objWord As Word.Application
> > Dim objDoc As Word.Document
> > Dim wordvalue As Variant
> > Dim j As Integer
> >
> > Dim lngErrNo As Long
> > Dim strErrSrc As String
> > Dim strErrDesc As String
> >
> > On Error GoTo PROC_ERR
> >
> > Application.DisplayAlerts = False
> > PrimaryDataWB.Activate '<<== this is my primary data file;
> > stored on my hard drive
> > Set objWord = New Word.Application
> > objWord.Visible = False
> >
> > Set objDoc = Documents.Open(myPathBATCH & "T and A.rtf")
> > 'the above file is stored on my hard
> > drive
> > objDoc.Activate
> > 'For "Rows" 1 - 8 in Table 1
> > For j = 1 To 8
> > wordvalue = objDoc.Tables(1).Columns(4).Cells(j + 2)
> > ActiveWorkbook.Sheets(3).Cells(j + 17, 11) =
> > Application.WorksheetFunction.Clean(wordvalue)
> > Next j
> >
> > objDoc.Close
> > objWord.Quit
> >
> > Set objDoc = Nothing
> > Set objWord = Nothing
> >
> > Exit Sub
> >
> > PROC_ERR:
> > lngErrNo = Err.Number
> > strErrSrc = "->ADJUSTMENT_TEST()->" & Err.Source
> > strErrDesc = Err.Description
> >
> > 'Disable error handling
> > On Error GoTo 0
> >
> > Err.Raise lngErrNo, strErrSrc, strErrDesc
> >
> > End Sub
> >
> > I have been able to determine that the macro crashes at the 'Set objWord =
> > ....' statement above.
> > Since I am running this logged-off, the above error trapping is doing
> > nothing for me.
> >
>
> Cindy Meister
> INTER-Solutions, Switzerland
>
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
>
http://www.word.mvps.org
>
> This reply is posted in the Newsgroup; please post any follow question or reply
> in the newsgroup and not by e-mail :-)
>
>