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*********

Re: Program to Automatically Save Word File by Helmut

Helmut
Wed Oct 26 17:27:42 CDT 2005

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.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"






Re: Program to Automatically Save Word File by Anne

Anne
Wed Oct 26 17:48:40 CDT 2005

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

"maperalia" <maperalia@discussions.microsoft.com> wrote in message
news:542AA2FE-1ABC-47DE-9A0F-5BB8FE728C82@microsoft.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,
> 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*********
>
>
>



Re: Program to Automatically Save Word File by maperalia

maperalia
Wed Oct 26 18:26:04 CDT 2005

Helmut;
Could you please advice me a friendly way to do this program?..

Best regards.
Maperalia

"Helmut Weber" wrote:

> 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.
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
>
>
>
>
>
>

Re: Program to Automatically Save Word File by Helmut

Helmut
Thu Oct 27 04:04:42 CDT 2005

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