PC Review
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Discussion
Re: From Word give over a date into Excel....
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Discussion
Re: From Word give over a date into Excel....
![]() |
Re: From Word give over a date into Excel.... |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
if I understood you correctly, you are trying to write a variable or value from Word into an Excel book. Try this in Word: Sub WriteValueToExcel() Dim XL As New Excel.Application Dim WB As Workbook Set XL = Excel.Application Set WB = XL.Workbooks.Open("c:\sample.xls") WB.Worksheets(1).Range("A1") = "Some text, value or variable" WB.Close True XL.Quit Set XL = Nothing End Sub Where ... "c:\sample.xls" is the path and file name of the workbook, "Worksheets(1).Range("A1")" is the sheet and cell in the workbook you want to fill and "Some text, value or variable" is a string or variable to be written to Excel. Don't forget to reference the Excel lib in Word (menu "Tools .... References .... Microsoft Excel X.X Object Library" in the Word VB-editor. Regards Max maxxstirner@gmx.net "Christoph" <kzsigmond@hotmail.com> schrieb im Newsbeitrag news:e3CIiAYODHA.1564@TK2MSFTNGP12.phx.gbl... > Hi, > > I would like to give a variable from Word into Excel so far I have this: > > Public Sub Verfallsdatum_Click() > DatumEingeben > DatumUbergeben > End Sub > > > Public Sub DatumEingeben() > > Dim Verfallsdate As Date > On Error GoTo ErrorHandler > > Verfallsdate = InputBox("Bitte ein Verfallsdatum eingeben(TT.MM.JJJJ):") > > > > Exit Sub > ErrorHandler: > > 'Set Verfallsdate = Nothing > MsgBox ("Bitte geben Sie eine gültige Datumformat ein") > > End Sub > Public Sub DatumUbergeben() > > Dim ObjXls > Dim xlwks As Object > Dim strfilename As String > Dim strLocation > > strLocation = strpath + "\" + strfilename > strpath = "C:\Documents and Settings\zka\Desktop\Projekt\Wr. > Städtische\Dokuverwaltung" > strfilename = "Datenuebergabe2.xls" > Set ObjXls = CreateObject("Excel.application") > Set xlwks = ObjXls.workbooks.Open(strLocation) > xlwks.GetDate > > > End Sub > > In excel: > > Public Sub getdate(Verfallsdate As Date) > Stop > End Sub > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

