Here is the Python code to list all files from Google Drive using the Google Drive API: # First, install the necessary packages using pip: # pip install google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client from google.oauth2.credentials import Credentials from googleapiclient.discovery import build # Replace with your own credentials.json file creds = Credentials.from_authorized_user_file('credentials.json', ['https://www.googleapis.com/auth/drive']) # Create a Drive API client service = build('drive', 'v3', credentials=creds) # Call the Drive API to list all files results = service.files().list( pageSize=10, # number of files to retrieve per page fields="nextPageToken, files(id, name, mimeType)").execute() items = results.get('files', []) # Print the results if not items: print('No files found.') else: print('Files:') for item in items: print(f'{item["name"]} ({item["id"]}) – {item["mimeType"]}') This code uses the google-auth, google-auth-oauthlib, google-auth-httplib2, and google-api-python-client packages to authenticate and interact with the Google Drive API. Replace the credentials.json file with your own API credentials, which you can obtain from the Google Cloud Console. The code then calls the files().list() method to retrieve a list of files and prints their names, IDs, and MIME types.
How to list all available Active Directory domains using .NET
Here is an example of .NET code that uses the System.DirectoryServices.ActiveDirectory namespace to list all available Active Directory domains: using System; using System.Collections.Generic; using System.DirectoryServices.ActiveDirectory; namespace ActiveDirectoryDomains { class Program { static void Main(string[] args) { // Get the current forest Forest currentForest = Forest.GetCurrentForest(); // Get a collection of all the domains in the forest DomainCollection domains = currentForest.Domains; // Print the name of each domain Console.WriteLine("Available Active Directory domains:"); foreach (Domain domain in domains) { Console.WriteLine("- " + domain.Name); } } } } This code uses the GetCurrentForest method to get the current forest and the Domains property to get a collection of all the domains in the forest. It then iterates through the collection and prints the name of each domain to the console. Note that you will need to have appropriate permissions to query Active Directory domains.
How to write data to Snowflake using .NET
Here is an example of .NET code that writes data to a Snowflake table using the Snowflake.Data library: using System; using System.Collections.Generic; using System.Data; using Snowflake.Data.Client; namespace SnowflakeWriter { class Program { static void Main(string[] args) { // Define the Snowflake connection string and credentials string connectionString = "account=<your-account>;user=<your-username>;password=<your-password>;db=<your-database>;schema=<your-schema>"; // Define the table name and columns string tableName = "people"; string[] columnNames = { "Name", "Age" }; // Create a list of Person objects to write to the table List<Person> people = new List<Person>() { new Person { Name = "John", Age = 30 }, new Person { Name = "Mary", Age = 25 } }; // Open a connection to Snowflake using (var connection = new SnowflakeDbConnection()) { connection.ConnectionString = connectionString; connection.Open(); // Create a command to insert data into the table using (var command = new SnowflakeDbCommand(connection)) { // Build the SQL insert statement string columns = string.Join(", ", columnNames); string values = string.Join(", ", columnNames); string placeholders = string.Join(", ", columnNames); string sql = $"INSERT INTO {tableName} ({columns}) VALUES ({placeholders})"; // Prepare the command command.CommandText = sql; command.CommandType = CommandType.Text; command.Parameters.Add(new SnowflakeDbParameter("Name", SnowflakeDbType.VARCHAR)); command.Parameters.Add(new SnowflakeDbParameter("Age", SnowflakeDbType.INT)); // Execute the command for each Person in the list foreach (var person in people) { command.Parameters[0].Value = person.Name; command.Parameters[1].Value = person.Age; command.ExecuteNonQuery(); } } // Close the connection connection.Close(); } Console.WriteLine("Data has been written to the Snowflake table."); } } class Person { public string Name { get; set; } public int Age { get; set; } } } This code defines the Snowflake connection string and credentials, as well as the table name and columns. It creates a list of Person objects to write to the table and uses the SnowflakeDbConnection and SnowflakeDbCommand classes from the Snowflake.Data.Client library to execute an insert statement for each Person in the list. Note that you may need to add a reference to this library in your project before you can use it.
How to write data to Hadoop using .NET
Here is an example of .NET code that writes data to a Hadoop table using the Microsoft.Hadoop.Avro library: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Hadoop.Avro.Container; using Microsoft.Hadoop.WebHDFS.Adapters; namespace HadoopWriter { class Program { static void Main(string[] args) { // Define the Hadoop cluster credentials and endpoint string clusterUri = "http://your-hadoop-cluster-uri/"; string userName = "your-hadoop-username"; string password = "your-hadoop-password"; // Define the Hadoop table location string tableLocation = "/your-table-location/"; // Define the Avro schema for the table string schema = @"{ ""type"": ""record"", ""name"": ""Person"", ""fields"": [ {""name"": ""Name"", ""type"": ""string""}, {""name"": ""Age"", ""type"": ""int""} ] }"; // Create a list of Person objects to write to the table List<Person> people = new List<Person>() { new Person { Name = "John", Age = 30 }, new Person { Name = "Mary", Age = 25 } }; // Write the list of Person objects to the Hadoop table using (var client = new WebHDFSClient(new Uri(clusterUri), userName, password)) using (var writer = AvroContainer.CreateWriter<Person>(new HdfsFileLocation(tableLocation), new AvroSerializerSettings { Resolver = new AvroDataContractResolver(), UseCache = true }, Codec.Deflate)) { foreach (var person in people) { writer.Write(person); } } Console.WriteLine("Data has been written to the Hadoop table."); } } class Person { public string Name { get; set; } public int Age { get; set; } } } This code defines the Hadoop cluster credentials and endpoint, as well as the location and Avro schema for the table. It creates a list of Person objects to write to the table and uses the AvroContainer and WebHDFSClient classes from the Microsoft.Hadoop.Avro and Microsoft.Hadoop.WebHDFS.Adapters libraries, respectively, to write the data to the table. Note that you may need to add references to these libraries in your project before you can use them.
Write data to OneDrive Web Excel using OfficeScripts
Here is an example of Office Script code that writes data to Microsoft Excel in OneDrive: function main(workbook: ExcelScript.Workbook) { // Get the active worksheet let sheet = workbook.getActiveWorksheet(); // Write data to the worksheet sheet.getRange("A1").setValue("Name"); sheet.getRange("B1").setValue("Age"); sheet.getRange("A2").setValue("John"); sheet.getRange("B2").setValue(30); sheet.getRange("A3").setValue("Mary"); sheet.getRange("B3").setValue(25); // Save the workbook to OneDrive workbook.save(); console.log("Data has been written to OneDrive."); } This code gets the active worksheet in the current workbook, writes some data to the first two columns, and saves the workbook to OneDrive. You can run this code by creating a new script in the Excel Online or Excel for Windows desktop application and pasting it into the script editor. You will need to make sure that you are signed in to your OneDrive account and have the appropriate permissions to save files to it.
Write data to Web Excel using .NET
Here is an example of .NET code that writes data to Microsoft Excel using the Microsoft.Office.Interop.Excel library: using System; using System.IO; using System.Reflection; using Microsoft.Office.Interop.Excel; namespace ExcelWriter { class Program { static void Main(string[] args) { // Create an instance of Excel application Application excel = new Application(); // Create a new Workbook Workbook workbook = excel.Workbooks.Add(); // Select the first Worksheet Worksheet worksheet = workbook.Worksheets[1]; // Write data to the Worksheet worksheet.Cells[1, 1] = "Name"; worksheet.Cells[1, 2] = "Age"; worksheet.Cells[2, 1] = "John"; worksheet.Cells[2, 2] = 30; worksheet.Cells[3, 1] = "Mary"; worksheet.Cells[3, 2] = 25; // Save the Workbook string path = Path.Combine(Environment.GetFolderPath( Environment.SpecialFolder.Desktop), "Data.xlsx"); workbook.SaveAs(path); // Close the Workbook and Excel application workbook.Close(); excel.Quit(); // Release COM objects to prevent memory leaks ReleaseObject(worksheet); ReleaseObject(workbook); ReleaseObject(excel); Console.WriteLine($"Data has been written to {path}"); } private static void ReleaseObject(object obj) { try { Marshal.ReleaseComObject(obj); obj = null; } catch (Exception ex) { obj = null; Console.WriteLine($"Exception occurred while releasing object: {ex.Message}"); } finally { GC.Collect(); } } } } This code creates a new Excel workbook, writes some data to the first worksheet, saves the workbook to the user’s desktop, and then closes Excel. Add a reference to the Microsoft.Office.Interop.Excel library in your project before you can use it. Also, make sure to release COM objects to prevent memory leaks.
PDF Automation using VBA
Dear friends, I’m excited to share with you a tutorial on how to automate real-world scenarios in PDF using VBA programming. You can watch the full video by clicking on the link below, or use the links in the Table of Contents to skip to specific sections. Tutorial link: link If you don’t have Acrobat Pro, you can download a free trial from the link below and install it. Download link: link Additionally, you can download a guide that provides detailed descriptions for the APIs that can be used to develop plug-ins for Acrobat and Adobe Reader®, as well as PDF Library applications. Below links are from my google drive but these are available in official sites too. Below links are from my google drive but these are available in official sites too.1. Developing Application Using Interapplication Communicationhttp://bit.ly/36YqpFW 2. Acrobat® and PDF Library API Reference: Adobe Acrobat SDKhttp://bit.ly/2FKdc7s Table of Contents:-1. Publish Excel, Word, Powerpoint to PDF using VBAhttps://youtu.be/uc6palG76Y8?t=60 2. How to create PDF Formhttps://youtu.be/uc6palG76Y8?t=394 3. Read all PDF Content using VBAhttps://youtu.be/uc6palG76Y8?t=499 4. Extract table from PDF using VBAhttps://youtu.be/uc6palG76Y8?t=1030 5. Read form fields in PDF using VBAhttps://youtu.be/uc6palG76Y8?t=1374 6. Write to PDF (Fill out a Form in PDF etc.) using VBAhttps://youtu.be/uc6palG76Y8?t=1764 7. Manipulate PDF document – combine multiple pdf pages using VBAhttps://youtu.be/uc6palG76Y8?t=2619 8. Manipulate PDF document – delete pdf pages using VBAhttps://youtu.be/uc6palG76Y8?t=3073 9. Convert PDF to word document using VBAhttps://youtu.be/uc6palG76Y8?t=3247 10. Convert PDF to Excel using VBAhttps://youtu.be/uc6palG76Y8?t=3247 11. Convert PDF to Web Page using HTML using VBAhttps://youtu.be/uc6palG76Y8?t=3247 12. Extract table manually PDF using Excel Power Query featurehttps://youtu.be/uc6palG76Y8?t=3685 13. Extract table manually PDF using Excel Power Query & VBAhttps://youtu.be/uc6palG76Y8?t=3685
Python to read Excel Data
To read an Excel file in Python, you can use the openpyxl library. Here is an example code that reads an Excel file and prints the data from cell A1 and A2: import openpyxl # load the Excel file workbook = openpyxl.load_workbook('example.xlsx') # select the sheet you want to read sheet = workbook.active # read data from cell A1 cell_a1 = sheet['A1'].value print(cell_a1) # read data from cell A2 cell_a2 = sheet['A2'].value print(cell_a2) In this example, we first load the Excel file called “example.xlsx” using the load_workbook method. Then we select the active sheet using the active property. We read the data from cell A1 using the sheet object and the cell reference ‘A1’. The value attribute returns the value of the cell. We do the same thing for cell A2, and finally, we print the values of both cells. Note that you can modify the code to read data from any other cell by changing the cell reference in the sheet object.
Read data from Excel using OfficeOpenXml .NET
To read an Excel file in .NET, you can use the EPPlus library. Here is an example code that reads an Excel file and prints the data from cell A1 and A2: using OfficeOpenXml; // Load the Excel file using (var package = new ExcelPackage(new FileInfo(@"example.xlsx"))) { // Select the sheet you want to read var sheet = package.Workbook.Worksheets[1]; // Read data from cell A1 var cell_a1 = sheet.Cells["A1"].Value.ToString(); Console.WriteLine(cell_a1); // Read data from cell A2 var cell_a2 = sheet.Cells["A2"].Value.ToString(); Console.WriteLine(cell_a2); } In this example, we first load the Excel file called “example.xlsx” using the ExcelPackage class. Then we select the first sheet in the workbook using the Worksheets property. We read the data from cell A1 using the Cells property and the cell reference “A1”. The Value property returns the value of the cell as an object, which we convert to a string using the ToString() method. We do the same thing for cell A2, and finally, we print the values of both cells using the Console.WriteLine() method. Note that you can modify the code to read data from any other cell by changing the cell reference in the sheet.Cells property.
VBA Create CommandBarButton on runtime
Here is example of how to create or delete Command bar button on runtime. Option Explicit Sub del_faceID() On Error Resume Next Application.CommandBars("faceid").Delete On Error GoTo 0 End Sub Sub add_faceID() Dim cmdBar As CommandBar, bt As CommandBarButton, i& del_faceID Set cmdBar = Application.CommandBars.Add _ (Name:="faceid", temporary:=True) cmdBar.Visible = True For i = 1 To 1000 Set bt = cmdBar.Controls.Add(Type:=msoControlButton, ID:=2950) bt.FaceId = i: bt.Caption = i Next i End Sub