Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cursor Position in VBE


Hi, I got the following code for inserting lines into my program:

Sub ImportModuleCode(ByVal wb As Workbook, _
ByVal ModuleName As String, ByVal ImportFromFile As String)
' imports code to ModuleName in wb from a textfile name
ImportFromFile
Dim VBCM As CodeModule
If Dir(ImportFromFile) = "" Then Exit Sub
On Error Resume Next
Set VBCM = wb.VBProject.VBComponents(ModuleName).CodeModule
If Not VBCM Is Nothing Then
VBCM.AddFromFile ImportFromFile
Set VBCM = Nothing
End If
On Error GoTo 0
End Sub

The problem is that it inserts the code from the file in the positio
that the cursor was set at.

How can I a) change the cursor position or b) make it insert the tex
from the file in the lines that I want

--
ehnt
-----------------------------------------------------------------------
ehntd's Profile: http://www.excelforum.com/member.php...fo&userid=1586
View this thread: http://www.excelforum.com/showthread.php?threadid=27446

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Cursor Position in VBE

Hi Ehntd,

The problem is that it inserts the code from the file in the position
that the cursor was set at.

How can I a) change the cursor position


Dim oCP As CodePane

'Move the cursor to line 10
Set oCP = VBCM.CodePane
oCP.SetSelection 10,0,10,0

or b) make it insert the text
from the file in the lines that I want?


Parse the file yourself (using VBA's File I/O) and use VBCM.InsertLines
to insert each line into the module.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cursor position? Marc Excel Discussion (Misc queries) 1 March 27th 05 07:09 PM
cursor position choice[_2_] Excel Programming 1 August 22nd 04 11:49 PM
cursor position Fan Fan Excel Programming 3 August 14th 04 01:12 AM
Position Cursor to A1 Dennis Damsgaard Excel Programming 3 June 8th 04 10:30 PM
cursor position NTL Excel Programming 1 January 18th 04 08:23 PM


All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"