Hello,
I am a little bit confused and I need some help. Using excel macro, I need to paste screens to given part of Word Doc, it's structure is like this:
The Word file has no bookmarks and I am not able to edit it.
Going further, my code is:
But it does nothing except of deleting entire file's content and paste screen at the button of the file.
Surprisingly this code works
but I cannot use it as I need to choose file where screens will be placed.
Any ideas how to fix it?
I am a little bit confused and I need some help. Using excel macro, I need to paste screens to given part of Word Doc, it's structure is like this:
HTML:
Heading1
...
Heading2
..
Heading3
..
The Word file has no bookmarks and I am not able to edit it.
Going further, my code is:
Code:
[/B]Private Function OpenDocs() As Object
Dim oApp As Word.Application
Dim intCount As Integer
Set oApp = GetApplication("Word.Application")
intCount = 3
If oApp Is Nothing Then
Exit Function
End If
With oApp
For intCount = 1 To .Documents.Count
If .Documents(intCount).Name Like "*trx*" Then
userform2.ComboBox1.AddItem .Documents(intCount).Name
End If
Next intCount
End With
If userform2.ComboBox1.ListCount > 1 Then
userform2.Show
Set wdSuppDoc = oApp.Documents(strWordDocName)
End If
userform2.ComboBox1.Clear
ThisWorkbook.Sheets(1).Range("c15") = wdSuppDoc.Name
'the part I'm talking about:
[B] wdSuppDoc.Goto What:=wdGoToHeading, Which:=wdGoToFirst, Count:=3, Name:=""[/B]
[B] 'wdSuppDoc.Range.Paste[/B]
End Function
Private Function GetApplication(ByVal AppClass As String) As Object
Const vbErr_AppNotRun = 429
On Error Resume Next
Set GetApplication = GetObject(Class:=AppClass)
If Err.Number = vbErr_AppNotRun Then
MsgBox "Please open Supporting Doc file first"
End If
On Error GoTo 0
End Function[B]
Surprisingly this code works
Code:
[/B] Dim wdApp As Word.Application Dim wdActiveDoc As Word.Document
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
On Error GoTo 0
'Check to see if we found an instance. If not you can create one if you desire
If wdApp Is Nothing Then
MsgBox "Please open Supporting Documentation File First"
Exit Sub
End If
If wdApp.Selection.Type = wdSelectionIP Then
wdApp.Selection.MoveRight Unit:=wdWord, Count:=1
End If
'Check if there are documents in the found instance of Word
wdSuppDoc.Range.Goto What:=wdGoToHeading, Which:=wdGoToFirst, Count:=intCtrl, Name:=""
wdApp.Selection.MoveUp Unit:=wdLine, Count:=1
wdApp.Selection.paste
[B]
but I cannot use it as I need to choose file where screens will be placed.
Any ideas how to fix it?