Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problems with Word


First of all thanks to all those who have helped with this problem.
However, I'm still having problems because I'm 2 months into VBA and my
code is just a cut and paste from google findings. I'm just going to
paste the entire code. Here are my problems:
1). I get a "the remote server machine does not exist" error sometimes
when I run this code (usually if its the first time running the macro).
2). Sometimes I don't get the correct Word document I want to run in
the macro; I get the previous document (this usually happens when
there's an error previously). I would have to go task manager and kill
WINWORD.exe then run the macro again.
**NOTE: I did update my reference to Word Object Library.
Can someone help me fix my code so I don't have to manually go into the
task manager?

Sub LetsGo()
Dim wrdApp As New Word.Application
Dim wrdDoc As Word.Document
Dim tString As String, tRange As Word.Range
Dim myNBR As Variant
Dim appwd As Object


On Error GoTo notloaded
Set appwd = GetObject("Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
End If
'appwd.Visible = True
On Error GoTo 0



With appwd
myNBR = Application.GetOpenFilename(FileFilter:="Word Files (*.doc),
*.doc", Title:="Please select a file")
End With
If myNBR = False Then
' They pressed Cancel
MsgBox "Stopping because you did not select a file"
Exit Sub
End If

Workbooks("4xMatrix-Grouping and Coding_v4").Activate
On Error Resume Next
Application.DisplayAlerts = False
Sheets("NBR Xfer").Delete
Application.DisplayAlerts = True
With Worksheets.Add
On Error Resume Next
..Name = "NBR Xfer"
On Error GoTo 0
End With


With Range("A1")
..Formula = "Word Document Contents:"
..Font.Bold = True
..Font.Size = 14
..Offset(1, 0).Select
End With
r = 3 ' startrow for the copied text from the Word document
Set wrdApp = CreateObject("Word.Application")
'wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open(myNBR)

With wrdDoc
For i = 1 To 10
Set oTableRge = wrdApp.Tables(i).Range
For Each oCell In oTableRge.Cells
If InStr(1, Left((oCell.Range.Text), Len(oCell.Range.Text)
- 1), "233 CTB Response is one of:", vbTextCompare) 0 Then
j = i
End If
Next
Next i
Set oTableRge = ActiveDocument.Tables(j).Range
For Each oCells In oTableRge.Cells


tString = Left((oCells.Range.Text), Len(oCells.Range.Text)
- 1)
If tString = Chr(160) & Chr(13) Then
GoTo Jump
Else
ActiveSheet.Range("A" & r).Formula = tString
r = r + 1
End If
Jump:
Next
..Close ' close the document
End With
wrdApp.Quit ' close the Word application
Set wrdDoc = Nothing
Set wrdApp = Nothing
ActiveWorkbook.Saved = True

Call ImportTranslation
End Sub


--
pikapika13
------------------------------------------------------------------------
pikapika13's Profile: http://www.excelforum.com/member.php...o&userid=10892
View this thread: http://www.excelforum.com/showthread...hreadid=547864

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with XLSTART in Word 2003 Lasse[_2_] Excel Discussion (Misc queries) 0 October 11th 07 02:44 PM
excel,word problems Cliffy38 Excel Discussion (Misc queries) 5 September 21st 07 10:10 PM
Problems when copying Excel into Word Sigi Rindler Excel Discussion (Misc queries) 2 January 24th 07 04:17 AM
Word/Excel Mailmerge problems havenlad Excel Discussion (Misc queries) 3 July 11th 06 03:45 PM
Corruption problems in Word? maggielynn Excel Discussion (Misc queries) 0 October 10th 05 03:32 PM


All times are GMT +1. The time now is 09:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"