Pegasus0990
Technical User
2) if i do "Wordcount" in Microsoft Word it gives me a certain amount of characters that exist in my document. but if i tell my code to delete that many characters as in
Selection.Delete Unit:=wdCharacter, Count:=1996
even if my document says that there are 1996 characters, it acutally always fall short. why? does anybody know a better way to delete this code? Note, I am using multiple bookmarks and i cannot have the code delete too many characters, else it will delete my bookmarks
[VBCODE]
Public Sub CommandButton1_Click()
HideListBoxes
Dim oDoc As Word.Document
Set oDoc = Application.Documents("C:\Documents and Settings\word.doc")
Dim oExcel As Excel.Application, myWB As Excel.Workbook
Set oExcel = New Excel.Application
Set myWB = oExcel.Workbooks.Open("C:\Documents and Settings\excel.xls")
h = 2
i = 4
j = 6
l = 7
If Worksheets("Calculations").Cells(1, 1) = "0" Then
Selection.GoTo What:=wdGoToBookmark, Name:="part1"
Selection.Delete Unit:=wdCharacter, Count:=1996
Else
If Worksheets("Calculations").Cells(2, 1) = "0" Then
Selection.GoTo What:=wdGoToBookmark, Name:="one"
With Selection
.EndOf Unit:=wdParagraph, Extend:=wdExtend
.TypeBackspace
End With
Selection.Delete Unit:=wdCharacter, Count:=985
End if
End Sub
[/VBCODE]
Selection.Delete Unit:=wdCharacter, Count:=1996
even if my document says that there are 1996 characters, it acutally always fall short. why? does anybody know a better way to delete this code? Note, I am using multiple bookmarks and i cannot have the code delete too many characters, else it will delete my bookmarks
[VBCODE]
Public Sub CommandButton1_Click()
HideListBoxes
Dim oDoc As Word.Document
Set oDoc = Application.Documents("C:\Documents and Settings\word.doc")
Dim oExcel As Excel.Application, myWB As Excel.Workbook
Set oExcel = New Excel.Application
Set myWB = oExcel.Workbooks.Open("C:\Documents and Settings\excel.xls")
h = 2
i = 4
j = 6
l = 7
If Worksheets("Calculations").Cells(1, 1) = "0" Then
Selection.GoTo What:=wdGoToBookmark, Name:="part1"
Selection.Delete Unit:=wdCharacter, Count:=1996
Else
If Worksheets("Calculations").Cells(2, 1) = "0" Then
Selection.GoTo What:=wdGoToBookmark, Name:="one"
With Selection
.EndOf Unit:=wdParagraph, Extend:=wdExtend
.TypeBackspace
End With
Selection.Delete Unit:=wdCharacter, Count:=985
End if
End Sub
[/VBCODE]