WordBasis insert command -- text length limit

A

a

I am using following code to insert text into the word document, using VB
from excel.

Any text which has length more than 240 characters is not getting inserted
into the document.

Any suggestions are highly appreciated.

Thanks,
----------------------------------------------------------------------------
------------------------------------

Sub GenerateADRFinding()

' Dimension the variables.
Dim PokeRange As Object
Dim Chan As Integer
Dim i As Long
Dim temps As String
Dim insertS As String

' Create an range object to poke.
Set PokeRange = Range("CheckList!a1")

' Initiate a channel to Word using a file as the topic.
Chan = DDEInitiate("WinWord", templateFile)

' Execute a few WordBasic commands.
DDEPoke Chan, "\StartOfDoc", PokeRange

i = 0
Do While i < 240 9 '(> 240 does not work)

temps = temps & "1"
i = i + 1
Loop

insertS = "[Insert "" " & temps & " "" ]"""

DDEExecute Chan, insertS
'DDEExecute Chan, "[FileSaveAll]"
DDEExecute Chan, "[FileExit]"

' Terminate the DDE channel.
DDETerminate Chan
 
H

Helmut Weber

Hi a,
does it have to be a DDE-connection?
Works beautifully in theory, according to my experience,
but not in practice, and cost me some money to find out.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
A

a

I am trying to create a word document based on certain checkbox selected
within Excel..

Scenario: There are two columns (A,B) and 100+ rows in Excel file. Column
"A" represents objects and Column "B" represents the description. The scope
of the initiative is to facilitate end clients to pick arbitrary objects and
display appropriate description of the object. To achieve this, I have
implemented a macro which reads the excel file and create a new sheet with
"A", checkbox, "B". This all is working fine.... however performance of the
sheet with 100 form checkboxes and assigned macro is reasonably slow.

Once the end clients selects number of checkboxes, attempt is to create a
report (WORD) with description of the selected objects....

Let me know what are the other options.
 
H

Helmut Weber

Hi,
just one possible way of controlling Word
from Excel and transferring data.
Set a reference to the word library
VBE, Extras, References...
---
Sub test222()
Dim i As Integer
Dim oWrd As Word.Application
Dim oDcm As Word.Document
Dim oWrk As Worksheet
Set oWrd = New Word.Application
Set oWrk = ActiveWorkbook.Worksheets(1)
oWrd.Visible = True ' or false if you like
Set oDcm = oWrd.Documents.Add
oDcm.SaveAs "c:\test\test444.doc"
For i = 1 To 10
oDcm.Range.InsertAfter oWrk.Cells(i, 1) & vbCr
Next
Stop ' or whatever
oDcm.Save
oDcm.Close
oWrd.Quit
Set oDcm = Nothing
Set oWrd = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top