| |

VerySource

 Forgot password?
 Register
Search
View: 927|Reply: 4

Consult VBA code into Delphi code

[Copy link]

2

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 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.00

Credits

Newbie

Rank: 1

Credits
0.00

 China

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

Use magic Report

0

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 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

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Unknown

Post time: 2020-7-23 14:15:01
| Show all posts
May I askGuderian(expert outpatient cleaner
How to convert this code?
Thank you!
   For Each cell In Selection
        msgbox(cell.value)
   Next cell
Reply

Use magic Report

0

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-7-24 14:30:01
| Show all posts
while Enum.Next(1, rgVar, vFetched) = S_OK do
  begin
    ShowMessage(rgVar);
    Inc(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-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list