Export text to TextBox into Excel

J

JCP

Good Afternoon,
Access 2003

I developed a module to open an excel file and then I would like export a
text from a form to textbox into excel.

My example works fine the len string is <255 characters. If is > add nothing
into text box.

Function ExportTextToExcel()

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim strText As String

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\BLK2DB\AllocSystSQL\Temp\NET
Statistics_2007.xls", , True)
Set xlBook = GetObject("C:\Test.xls")

With xlBook.Application
.Visible = True
.Windows(1).Visible = True
End With

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'testing

strText = CVar(Forms!zzz!CmtsEng)
Debug.Print Len(strText)

'xlBook.Sheets(1).Shapes("Text Box 15").TextFrame.Characters.Text = strText

xlBook.Sheets(1).Shapes.AddTextbox(msoTextOrientationHorizontal, _
10, 400, 400, 200).TextFrame.Characters.Text = strText

'Remarks, it works if len(strText) <=255 characters
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Set xlBook = Nothing
Set xlApp = Nothing

End Function


Questions:
1. What is wrong in my function? I believe and I hope export text if the len
is >255.
2. If the text has paragraph in excel textbox shows small squares. How can i
remove these squares?
3. What can I add in my function to detect if Text.xls is open? If is open,
the code should be close without save and then open it again.

I appreciate your help.

Thanks a lot
jcp
 

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