![]() |
|
#7
|
||||
|
||||
|
I think you are trying to do have the work in Excel and half in Word. For simplicity it would be easiest to do all this in Excel and not bother with running code in Word itself (unless those same macros need to be run independent of this at other times in Word)
What if the Excel code was rewritten to Code:
Sub Open_Word_Doc()
Dim WRD As Object, aDoc as object
On Error Resume Next
Set WRD = GetObject(, "Word.Application")
If Err.Number Then
Err.Clear
Set WRD = CreateObject("Word.Application")
End If
On Error GoTo 0
With WRD
.Visible = True
.Application.WindowState = wdWindowStateMaximize
.Application.ScreenUpdating = True
set aDoc = .Documents.Add Template:="[Path to .dot file]", NewTemplate:=False
With aDoc.Variables
.Item("varAuth").Value = "None"
.Item("varProjNum").Value = "0"
.Item("varProjName").Value = "None"
.Item("varDefl").Value = 0
End With
aDoc.Bookmarks("Width").Range.Text = ActiveWorkbook.Sheets(1).Cells(1,1).Value
''If you need to also call a userform to provide more parameters to pass into Word, do it here using a userform created in Excel
aDoc.Range.Fields.Update
End With
Set aDoc = Nothing
Set WRD = Nothing
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Could somebody help me with the code of my VBA userforms(Combibox - saving - editing of data) | 19339 | Excel Programming | 2 | 09-14-2018 12:06 AM |
| Is it possible to have menubar in userforms | srinivasaru | Excel Programming | 3 | 03-22-2017 03:53 AM |
| using office icons on userforms controls | fraz627 | Excel | 0 | 05-02-2014 06:02 PM |
Multiple Userforms Displaying Different Content but Returning Same Content?
|
marksm33 | Word VBA | 1 | 02-24-2014 06:17 PM |
looping controls on userforms
|
Cbrehm | Excel Programming | 5 | 05-11-2011 02:53 AM |