LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Starting Excel from Word


Hi

The idea behind the code below is to open an Excel sheet from Word. Th
Excel Sheet serves as an ini-file. The Excel is opened as visible
false. So far the code is working. But my problem is (see the bol
passages) the "i"-counter. It changes but the value in xfilenam
"xfilename
objXLApp.workbooks("IntCoverage.xls").Worksheets(" Coverage").Range("G
& i) & ".doc" stays always the same. If I open the Excel with visible
true it works. Is there also a solution with visible = false?

Thanks for you help
Michael




Sub Update()

Dim savename As String
Dim xfilename As String
Dim macro_name As String
Dim i As Integer

Dim objXLApp As Object
Set objXLApp = CreateObject(Class:="Excel.Application")
objXLApp.workbooks.Ope
("R:\APS\AMR\REPB\IntCompanies\_Companies\IntCover age.xls")

i = 9

Do
'objXLApp.workbooks.Active
XFILENAME
OBJXLAPP.WORKBOOKS(\"INTCOVERAGE.XLS\").WORKSHEETS (\"COVERAGE\").RANGE(\"G\
& I) & \".DOC\"
MACRO_NAME
OBJXLAPP.WORKBOOKS(\"INTCOVERAGE.XLS\").WORKSHEETS (\"COVERAGE\").RANGE(\"E\
& I) & \"_\"
SAVENAME
OBJXLAPP.WORKBOOKS(\"INTCOVERAGE.XLS\").WORKSHEETS (\"COVERAGE\").RANGE(\"C\
& I) & \"_1.DOC\"[/b]
IF XFILENAME = \".DOC\" THEN EXIT DO

DIM FS, F
SET FS = CREATEOBJECT(\"SCRIPTING.FILESYSTEMOBJECT\")
SET F = FS.GETFOLDER(XFILENAME)

IF FS.FILEEXISTS(XFILENAME) = TRUE THEN
DOCUMENTS.OPEN FILENAME:=(XFILENAME)

APPLICATION.RUN MACRONAME:=(MACRO_NAME)
ACTIVEDOCUMENT.SAVE

CHANGEFILEOPENDIRECTOR
\"R:\APS\AMR\REPB\INTCOMPANIES\_UPDATE\\"
ACTIVEDOCUMENT.SAVEAS FILENAME:=(SAVENAME)
FILEFORMAT:=WDFORMATDOCUMENT, _
LOCKCOMMENTS:=FALSE, PASSWORD:=\"\", ADDTORECENTFILES:=TRUE
WRITEPASSWORD _
:=\"\", READONLYRECOMMENDED:=FALSE, EMBEDTRUETYPEFONTS:=FALSE
_
SAVENATIVEPICTUREFORMAT:=FALSE, SAVEFORMSDATA:=FALSE
SAVEASAOCELETTER:=FALSE

ACTIVEDOCUMENT.CLOSE SAVECHANGES:=WDDONOTSAVECHANGES

END IF

[b] I = I +

Loop Until xfilename = ""

objXLApp.Quit
Set objXLApp = Nothing

Application.DisplayAlerts = True

End Su

--
MichaelS
-----------------------------------------------------------------------
MichaelS_'s Profile: http://www.excelforum.com/member.php...fo&userid=2640
View this thread: http://www.excelforum.com/showthread.php?threadid=51716

 
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
keyboard is locked after starting in both word and excel kfaul Excel Discussion (Misc queries) 0 November 18th 08 03:48 PM
how to keep a word of same sentence starting w a capital next lin dottie Excel Worksheet Functions 1 September 20th 07 05:32 PM
separate a Capital starting word from a sentence Rasoul Khoshravan Excel Worksheet Functions 3 October 25th 06 06:31 PM
Starting Excel sam[_4_] Excel Programming 1 November 24th 03 06:37 PM
Starting a userform upon starting the file Fritznel Excel Programming 1 July 28th 03 05:37 AM


All times are GMT +1. The time now is 04:20 AM.

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

About Us

"It's about Microsoft Excel"