I have a program that saves as excel and word file with the same filename
(see program below). The excel file is being saved without problem, however,
the word file it is not working at all.
Could you please help me with this matter?.. I think that even the
description I wrote under the word program are completely wrong.
Thanks.
Maperalia
‘*****Start of Program*********
Option Explicit
Public Sub OpenWordAndUpdateLinks()
SaveExcelTemplateAsSaveAs
SaveWordTemplatelAsSaveAs
End Sub
Sub SaveExcelTemplateAsSaveAs()
Dim WO As String
Dim grdprp As String
Dim sFilename As String
Dim Progname As String
Dim Filename As String
Dim myDateTime As String
WO = Worksheets("summary BLR").Range("M10")
myDateTime = Format(Worksheets("summary BLR").Range("M9").Value,
"yyyymmdd")
Filename = "" & WO & "_" & myDateTime & ""
Progname = "C:\Form\" & Filename & ".xls"
ActiveWorkbook.SaveCopyAs Progname
End Sub
'***********OPEN THE TEMPLATE WORD FILE AND SAVE
AS****************************
Sub SaveWordTemplatelAsSaveAs()
Dim wordApp As Object
Dim fNameAndPath As String
Dim Filename As String
Dim WO As String
Dim myDateTime As String
WO = Document("Page 1,Section 1",At 2.1").Range("ln 1,col 2 to ln 1, col
19")
myDateTime = Document("Page 1,Section 1",At 2").Range("ln 2,col 7 to ln
2,col 19")
fNameAndPath = "C:\Word\Template.doc"
Set wordApp = CreateObject("Word.Application")
wordApp.Documents.Open (fNameAndPath)
wordApp.Visible = True
wordApp.Activate
Filename = "" & WO & "_" & myDateTime & ""
Progname = "C:\Form\" & Filename & ".doc"
ActiveDocument..SaveCopyAs Progname
End Sub
'**********************************************************
‘*****End of Program*********
Helmut Weber - 26 Oct 2005 23:27 GMT
Hi Maperalia,
> Dim WO As String
> WO = Document("Page 1,Section 1",At 2.1").Range("ln 1,col 2 to ln 1, col
>19")
the way You are trying to create a filename is a nightmare!
Don't!
Besides that, You can't use " for "inch" without getting
problems, as " is used as string delimiter.
Don't know where to begin.
Start from scratch, sorry to say so.

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
maperalia - 27 Oct 2005 00:26 GMT
Helmut;
Could you please advice me a friendly way to do this program?..
Best regards.
Maperalia
> Hi Maperalia,
>
[quoted text clipped - 10 lines]
> Don't know where to begin.
> Start from scratch, sorry to say so.
Helmut Weber - 27 Oct 2005 10:04 GMT
Hi Maperalia,
I assume, You want to control Word from Excel,
and You got all working for an Excel-workbook.
You have a string like: "c:\test\4000\Projekt02"
Add ".xls" for the workbook name.
Add ".doc" for the document name.
' ---
Dim sNamePart As String
Dim sNameExcl As String
Dim sNameWord As String
sNamePart = "c:\test\4000\Projekt02"
sNameExcl = sNamePart & ".xls"
sNameWord = sNamePart & ".doc"
' --- plus
' reference to word set
' word already running
' only one word doc open
Dim oWrd As Word.Application
Dim oDcm As Word.Document
Set oWrd = GetObject(, "Word.Application") ' Comma !!!
Set oDcm = oWrd.ActiveDocument
oDcm.SaveAs sNameWord
First simply try to save a word doc from excel at first.
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Anne Troy - 26 Oct 2005 23:48 GMT
I'm no programmer, but I suggest you look into using bookmarks. Then perhaps
you could much more easily find that location. :)
************
Anne Troy
www.OfficeArticles.com
>I have a program that saves as excel and word file with the same filename
> (see program below). The excel file is being saved without problem,
[quoted text clipped - 62 lines]
>
> '*****End of Program*********