PDA

View Full Version : NUMBERS HELP



oleg_v
01-31-2010, 11:37 PM
Hi
I have this code:
Sub XLToWordTable_3()
Dim ObjWord As Object
Dim wrdDoc As Object
Dim k As Integer


'Set the Word Object
Set ObjWord = CreateObject("Word.Application")

'Create a Document based on the template TableTest.dot
'You'll need to create the template ahead of time.

Set wrdDoc = ObjWord.Documents.Open(Filename:="C:\Documents and Settings\ovolfson\Desktop\function\KKK.doc")


'If there is more than one

'table, but sure to change it here.

With wrdDoc.Tables(18)


.Cell(4, 7) = CStr(Sheets("Sheet2").Range("B" & 3).Value)

End With

MyMonth = Left(MonthName(Month(Date)), 3)
MyDay = Day(Date)
Dim retv, d
d = Now
retv = Right("00" & Hour(d), 2) & Right("00" & Minute(d), 2)
MyFileName = MyMonth & "_" & MyDay & "_" & retv
'close and save .doc
myvar = Worksheets("Sheet1").Range("d1").Value

wrdDoc.SaveAs "C:\Documents and Settings\ovolfson\Desktop\function\" & myvar & "_" & MyFileName & ".doc" 'change file name to suit
wrdDoc.Close SaveChanges:=False
Set wrdDoc = Nothing
ObjWord.Quit
Set ObjWord = Nothing
Exit Sub
ErFix1:
On Error GoTo 0
MsgBox "error"
Set wrdDoc = Nothing
ObjWord.Quit
Set ObjWord = Nothing

End Sub

i have 1 problem when i transfer the numbers from excel to word:

when i have in excel cell the number looking like "0.05" or "0.5" when it transfers to word it looks like "05." or "5."
what can i do to make the numbers stay in their original form


Thanks

Oleg

Aussiebear
01-31-2010, 11:58 PM
Please go back to your post and wrap the code supplied with VBA tags

oleg_v
02-01-2010, 12:03 AM
i do not understand what i need to do??

oleg_v
02-01-2010, 12:37 AM
Hi
I have this code:

Sub XLToWordTable_3()
Dim ObjWord As Object
Dim wrdDoc As Object
Dim k As Integer


'Set the Word Object
Set ObjWord = CreateObject("Word.Application")

'Create a Document based on the template TableTest.dot
'You'll need to create the template ahead of time.

Set wrdDoc = ObjWord.Documents.Open(Filename:="C:\Documents and Settings\ovolfson\Desktop\function\KKK.doc")


'If there is more than one

'table, but sure to change it here.




With wrdDoc.Tables(18)









.Cell(4, 7) = CStr(Sheets("Sheet2").Range("B" & 3).Value)



End With




MyMonth = Left(MonthName(Month(Date)), 3)
MyDay = Day(Date)
Dim retv, d
d = Now
retv = Right("00" & Hour(d), 2) & Right("00" & Minute(d), 2)


MyFileName = MyMonth & "_" & MyDay & "_" & retv

'close and save .doc
myvar = Worksheets("Sheet1").Range("d1").Value


wrdDoc.SaveAs "C:\Documents and Settings\ovolfson\Desktop\function\" & myvar & "_" & MyFileName & ".doc" 'change file name to suit
wrdDoc.Close SaveChanges:=False
Set wrdDoc = Nothing
ObjWord.Quit
Set ObjWord = Nothing
Exit Sub
ErFix1:
On Error GoTo 0
MsgBox "error"
Set wrdDoc = Nothing
ObjWord.Quit
Set ObjWord = Nothing


End Sub]



i have 1 problem when i transfer the numbers from excel to word:

when i have in excel cell the number looking like "0.05" or "0.5" when it transfers to word it looks like "05." or "5."
what can i do to make the numbers stay in their original form


Thanks

Oleg

Aussiebear
02-01-2010, 12:38 AM
Select your section of code and then click on the green vba button. This formats the code correctly and makes everything so much easier to read.

oleg_v
02-01-2010, 12:45 AM
is it right in mt previous post

Aussiebear
02-01-2010, 01:48 AM
No. Click on EDIT, then highlight your section of code then click on the green VBA button

oleg_v
02-01-2010, 03:34 AM
I did what you asked.

Bob Phillips
02-01-2010, 05:04 AM
Sub XLToWordTable_3()
Dim ObjWord As Object
Dim wrdDoc As Object
Dim k As Integer


'Set the Word Object
Set ObjWord = CreateObject("Word.Application")

'Create a Document based on the template TableTest.dot
'You'll need to create the template ahead of time.
Set wrdDoc = ObjWord.Documents.Open(Filename:="C:\Documents and Settings\ovolfson\Desktop\function\KKK.doc")

'If there is more than one
'table, but sure to change it here.
With wrdDoc.Tables(18)

.cell(4, 7) = CStr(Sheets("Sheet2").Range("B" & 3).Text)
End With

MyMonth = Left(MonthName(month(Date)), 3)
MyDay = day(Date)
Dim retv, d
d = Now
retv = Right("00" & Hour(d), 2) & Right("00" & Minute(d), 2)

MyFileName = MyMonth & "_" & MyDay & "_" & retv

'close and save .doc
myvar = Worksheets("Sheet1").Range("d1").Value

wrdDoc.SaveAs "C:\Documents and Settings\ovolfson\Desktop\function\" & myvar & "_" & MyFileName & ".doc" 'change file name to suit
wrdDoc.Close SaveChanges:=False
Set wrdDoc = Nothing
ObjWord.Quit
Set ObjWord = Nothing
Exit Sub
ErFix1:
On Error GoTo 0
MsgBox "error"
Set wrdDoc = Nothing
ObjWord.Quit
Set ObjWord = Nothing
End Sub