Message Boards Message Boards

GROUPS:

VBA optional arguments using NETLink

Posted 3 months ago
212 Views
|
0 Replies
|
0 Total Likes
|

I'm using NETLink to modify an Excel file. I'd like to copy a sheet and put it after a specified sheet. The Microsoft documentation for the copy function is here. I can't figure out how to set an optional argument for the copy function.

example code:

Needs["NETLink`"]
InstallNET["Force32Bit"->True]
excelObj=CreateCOMObject["Exel.Application"]
wb=excelObj@Workbooks@Open["~/example.xlsx"]
sheets=wb@Worksheets
sheets[1]@Copy[(*what do I put here?*),sheets[1]]

In this example code I'm trying to copy the first sheet and insert the new sheet after the first sheet. There are workarounds, but in general, how do I deal with optional arguments like this using NETLink?

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract