| |

VerySource

 Forgot password?
 Register
Search
View: 12|Reply: 2

Consult VBA code into Delphi code

[Copy link]

2

Threads

2

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

Post time: 2020-3-5 09:30:01
| Show all posts |Read mode
Sub Count_Selection ()
Dim cell As Object
Dim count As Integer
count = 0
For Each cell In Selection
count = count + 1
Next cell
MsgBox count&"item (s) selected"
End Sub
Reply

Use magic Report

1

Threads

2

Posts

0

Credits

Newbie

Rank: 1

Credits
0

 China

Post time: 2020-3-5 16:55:11
| Show all posts
看不懂,不知道你是什么意思
Reply

Use magic Report

0

Threads

5

Posts

6

Credits

Newbie

Rank: 1

Credits
6

 China

Post time: 2020-5-27 22:15:02
| Show all posts
uses ActiveX;

procedure TForm1.Button1Click (Sender: TObject);
begin
  ExcelApplication1.Connect;
  ExcelApplication1.Workbooks.Add (EmptyParam, 0);
  ExcelApplication1.Visible [0]: = True;
  (ExcelApplication1.Worksheets.Item [1] as _Worksheet) .Range ['E1', 'E5']. Select;
end;

procedure TForm1.Button2Click (Sender: TObject);
var
  Enum: IEnumVariant;
  Selection: OleVariant;
  Application: OleVariant;
  Count: Integer;
  rgVar: OleVariant;
  vFetched: Longword;
begin
  Application: = ExcelApplication1.Application;
  Selection: = Application.Selection;
  Enum: = IUnknown (Selection._NewEnum) as IEnumVariant;
  Count: = 0;
  while Enum.Next (1, rgVar, vFetched) = S_OK do Inc (Count);
  ShowMessage (IntToStr (Count));
end;
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list