Using Flow to Integrate Dynamics CRM and SharePoint

A manufacturing company's sales staff visits a client, they are required to fill out a “Visit Report” so that others in the company can review their information. The client wanted to store these reports in SharePoint because Dynamics 365 licenses are more expensive than the general Office 365 licenses, which SharePoint is a part of.

Visit Reports were created as an entity related to accounts in the Dynamics 365 system.

Steps performed:

  1. Set up Document Management sync between Dynamics 365 and SharePoint Online.
  2. Create a content type in SharePoint and associate a Word template with it.
  3. Go into Microsoft Flow and create a blank flow.
  4. Add a “trigger” from Dynamics 365 which will launch the flow whenever a record is created or updated in Visit Reports.
  5. Add an “action” from Dynamics 365 to get a record from the Account entity.
  6. Select the correct organization name (i.e. your company’s main tenant; ours is “MRS Company Limited”), select “Accounts”, and for the Item Identifier, we chose “Customer” from the list of dynamic content.

  7. Add an action to “Get file content” from SharePoint library Visit Report. This will be the blank template for Visit Report.
  8. The flow will prompt you for the site address and file identifier. Under site address, select/enter the URL for the SharePoint site. For File Identifier, select the template from the library location.
  9. Add another action step to create the file in the SharePoint library “Visit Reports”.
  10. Under site address, enter the URL for the document’s destination location in SharePoint. For the folder path, select the exact library. In this case, it is “/sti_visitreports”. For File Name, select Account Name from the Get Record step (see above) and Visit Date from the date the location was created/updated. For File Content, select File Content from the Get File Content step. See the screenshot below:
  11. The final step is to add an action to update file properties. From here, select the URL and SharePoint document library, and then enter the ItemID from the Create File step. At this point, you can add any metadata that is required via the dynamic content tab.
  12. Click save and start testing!

Learn Oracle E-Suite

https://learn.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=904&get_params=cloudId:243,objectId:23306

LEJ Knowledge Hub

LEJ Knowledge Hub

Instance Segmentation Algorithm

https://www.youtube.com/watch?v=yt1RSUw0YO4

Artificial Intelligence 101: How to get started

https://www.hackerearth.com/blog/artificial-intelligence/artificial-intelligence-101-how-to-get-started/

Learn Python 2

https://www.codecademy.com/courses/learn-python

7 steps to learn Artificial Intelligence

1. Pick a problem you’re interested in.


Starting with a problem you want to solve makes it a lot easier to stay focused and motivated to learn, instead of starting with an intimidating, disconnected list of topics (you’re a Google search away from many of lists of machine learning resources, I’m not providing another one here). Solving a problem also forces you to deeply engage with machine learning, instead of passively reading about it.

Good problems to start with have several criteria:
  • They cover an area you’re personally interested in.
  • Data is readily available that’s well-suited to addressing the problem (otherwise 
           the bulk of your time will go here).
  • You can work with the data (or some relevant subset of it) comfortably on a single machine.
Don’t have a problem that comes to mind? No worries! We provide a nice onramp of
machine learning problems at Kaggle through our getting started competition series.
Start off on the titanic competition.

2. Make a quick, dirty, hacky, end-to-end solution to your problem.
It’s really easy to get bogged down in one implementation detail or carefully tuning the
wrong machine learning algorithm. You want to avoid this.
Your goal here is to get something super basic in place as quickly as possible that covers
the end-to-end problem, from reading in the data, processing it into a form suitable for
machine learning, training a basic model, creating a result, and evaluating its performance.
3. Evolve and improve your initial solution.
Now that you have a functional baseline, it’s time to get creative. Try improving each
component of your initial solution, and measure the impact to see where it makes sense
to spend time. Many times acquiring more data or improving data cleaning and
preprocessing steps have a higher ROI than optimizing the machine learning models
themselves.
Part of this step should include being hands-on with the data - inspecting individual rows
and visualizing distributions to have a better understanding of it's structure and oddities.
4. Write up and share your solution.
The best way to get feedback on your solution is to write it up and share it. Writing about
your solution mean you’ll engage with it in a new way and understand it better. This
enables others to understand what you’ve done and provide feedback, helping you learn.
It also kickstarts your machine learning portfolio, which will help showcase your abilities
and get a job.
Kaggle Datasets and Kaggle Kernels are an effective way to share your data and solution,
get feedback from others, and also see how others extend your problem. This starts
fleshing out your Kaggle profile as well.
5. Repeat #1-4 across a diverse set of problems.
Now that you’ve done this for a single problem that you’re interested in, do this several
more times across a different set of domains.
Did you start off with tabular data? Work on a problem that involves less structured text,
and another that solves images.
Was the machine learning problem structured for you initially? Alot of the creative and
valuable work is figuring out how to go from a loosely-defined business or research
objective to a well-defined machine learning problem in the first place. Work through this
for one problem type.
Kaggle Competitions and Kaggle Datasets provide a good starting point for both
well-defined machine learning problems and raw data sources that’d be suitable
for machine learning.
6. Seriously compete in a Kaggle competition (if you’ve not already done so).
Giving your best shot at the same problem that thousands of others are hard at work
on is a tremendous learning opportunity: it forces you to iterate on the problem over
and over again, and then exposes you to what works effectively on the problem.
The forums for an individual competition are a rich resource on how others are
approaching it and debugging issues with your approach, kernels provide exploratory
insights about the data along with an easy way to get started on a problem, and
the winning blog posts at the end showcase what ultimately worked best.
Kaggle Competitions also provide a unique opportunity to team up with others. Our
community has a diverse set of background and skills, so everyone has something to
teach and something to learn. You never know, you may meet your future colleague
on Kaggle!
7. Apply machine learning professionally.
This enables you to spend most of your time on machine learning and really helps you
level up. Deciding on the type of role you’d like to pursue and building a personal
portfolio of projects related to this is a strong starting point. If you’re not ready to start
interviewing for machine learning positions, then taking on new projects in your current
role, seeking consulting opportunities, and getting involved with civic hackathons and
data-related community service opportunities are additional ways to get a foothold.
Professional work often requires and is greatly enhanced by strong programming
abilities - improving this with focused projects yields many downstream payoffs.
Valuable opportunities for professional machine learning work include:
  • Applying machine learning in production systems.
  • Focusing on machine learning research and pushing the state of the art forward.
  • Leveraging machine learning in exploratory analyses to improve product and 
           business decisions.

New Features of Microsoft Dynamics GP 2018

  1. Copy Workflow Steps

I’m very much into the workflow side of things; I’ve blogged quite a bit about it, written two books on it, and Microsoft invited me to write a guest post on workflow as part of the Feature of the Day series for the launch of Microsoft Dynamics GP 2018. So, for me, the best new feature was one that I actually requested: the ability to copy workflow steps.
You can’t use parentheses in step conditions, so you can’t easily define multiple conditions. If you have several steps which were mainly the same, you had to duplicate them manually, which was unnecessarily time to consume. Now, however, you can easily copy your step, including child steps, which cuts down the effort of creating workflow steps quite a lot. This saves your staff a lot of their working time – and that inevitably means your business is saving money.
  1. Enhancements to the Web Client

Although GP used to be just a desktop client, it can now also be hosted on Azure or on-premise and you get access to the web client version, on any device you want. That means you don’t have to be in the office or on the network, you can fire up your web browser and go to the webpage, log on and there’s GP on your tablet or laptop.
This greatly increases the accessibility of GP as your employees can work on the go. You’re getting the most out of there time. Business is becoming increasingly mobile and it’s great that people can use GP whilst traveling on the train, out of office hours or even on their own devices.
  1. New Password Protected SmartList Favourites

SmartList is an ad hoc reporting tool that lets you take control of your data by customizing reports with the columns and search criteria that you want. You’re able to save a favorite that will remember your search criteria and column selection. In this new update, you can now password protect these favorites, meaning other users cannot delete or modify your SmartLists without the password.
Now, your report configuration is so much more secure. This change is something clients always ask me about so I know this will be quite a significant feature, saving both time and effort for many users.
  1. Improvements to the document attachment function

This handy module on GP provides the ability to scan or attach Word documents, PDFs or Excel sheets to records in GP. They’ve made this feature easily accessible on the action pane, and that saves people time for routine tasks. It means if, for example, when you get a quote through from your supplier, you can now simply attach it to purchase requisition than send it through a workflow for approval. That attachment will be emailed to the approver as well – and they don’t even need to be a GP user, which saves on licensing costs.
It’s a more organized way of bringing together and electronically storing important historic documents in a centralized repository. You can see when and by who documents have been attached to a record as well as recalling the document to view, instead of needing to trawl through an archive of printed documents. Your business can really benefit from such effortless efficiency.
  1. Changes to the purchasing system

GP has traditionally been very American-centric, and because of this everything has been about cheque payments. However, especially in the UK, everyone does electronic funds transfer (EFT) payments. This might sound like a relatively small thing, wording changes, but I know it’s been frustrating for UK users. In response to this Microsoft have now renamed all windows containing the word “cheques” to use the word “payment” instead; so “Select Cheques” has become “Build Payment Batch”.
It just makes much more sense and it’s updating the system for the type of payments people actually do in the system. Making these changes shows Microsoft’s commitment to improving the usability of the platform for UK users – we are just as important as the USA.

Changing the posting type on an account after you close the year in General Ledger for Microsoft Dynamics GP

Microsoft Dynamics GP 2013 R2 (12.00.1745) and higher versions:

New functionality was added that will allow you to reopen a year yourself that was already closed successfully. With this new functionality, you can reopen the GL year, change the posting type on the GL Account setup, and simply reclose the GL Year again so the account closes properly. To do this, follow these steps:

1. Have all users exit all companies, and make a current backup of the company database.

Note: If any other users are logged into any company in this Microsoft Dynamics GP installation, you will get a message "You cannot reverse the historical year because other users are logged in to the system." All users need to be logged out of all companies. 

2. Click on Microsoft Dynamics GP, point to Tools, point to Routines, point to Financial and click Year-End Closing.

3. In the Year-End Closing window, click on the Reverse Historical Year button at the bottom.

4. Click Process to reopen the last closed historical year as shown in the Year to Open field.  

5. Click Continue to verify that you have made a backup of the company database. If not, click Cancel and make a backup of the company database before proceeding.

Note: This process will physically move all the historical data from the GL history table to the GL Open Transaction table, and reverse all the Beginning Balance Entries that we brought forward. This process will reopen the GL year as if it was never closed in the first place.

6. Once the year is reopened, the next historical year will populate the window so you can repeat for as many years as you need to be reopened. The historical years can only be reopened in consecutive order starting with the most previously closed year. Just exit out of these windows once you have the year(s) you want to be reopened.

7. Next click on Cards, point to Financial and click Account. Select the GL account you need and change the Posting Type field to Balance Sheet or Profit and Loss as needed and click Save.

8. When you have finished editing the GL account type, click on Microsoft Dynamics GP, point to Tools, point to Routines, point to Financial and click Year-End Closing and reclose the GL year again. Print/review the Year End Closing report as desired.

Note: When you reopen and reclose a GL year, make sure that the Retained Earnings account being used has not changed, and that no historical data has been purged from that year. 

9. Verify the GL account has or doesn't have a beginning balance as needed. 


Q: Why are some Beginning balances different for GL accounts in which I did not change the posting type? 

A: The system allows you to post one historical year back and it creates separate BBF entries for those transactions. However, now if you reopen and reclose the year, those transactions will now be included in the new BBF entry as if it was actually keyed during the open year. It is now considered a current year transaction for that year rather than a historical year posting and will be included in the BBF entry that is recalculated. 

Microsoft Dynamics GP 2013 SP2, Microsoft Dynamics GP 2010, Microsoft Dynamics GP 10.0 and all prior versions:

Use one of the following methods to correct the posting type for the next year.

• If the account is supposed to be a profit-and-loss account, use Method 1 below.

• If the account is supposed to be a balance sheet account, use Method 2 below.

Note Before you follow the instructions in this article, make sure that you have a complete backup copy of the database that you can restore if a problem occurs.

Method 1: The account is supposed to be a 'profit-and-loss' account

As a balance-sheet account, this account will have a beginning balance after the year-end closing process is completed. To change the account to a profit-and-loss account and to reverse the beginning balance, follow these steps:

On the Cards menu, point to Financial, and then click Account. In the Account Maintenance window, type the account number in the Account field. Make sure that the Posting Type area is set to Balance Sheet, and then click Save. The type needs to be Balance Sheet type at this point so we offset the balance that was carried forward and it doesn't affect the RE account now. 

Use one of the following methods, depending on whether you are registered for multicurrency or not registered:

If you are registered for Multicurrency Management in Microsoft Dynamics GP, follow these steps:
In Microsoft Dynamics GP, point to Tools on the Microsoft Dynamics GP menu, point to Setup, point to Financial and then click Multicurrency.

In the Maintain History area, click to clear the General Ledger Account checkbox.
If you are not registered for Multicurrency Management, open SQL Server Management Studio and run the following statement against the company database:
UPDATE MC40000 SET MNSUMHST = 0

Change the Maintain History settings in the General Ledger Setup window so we don't keep the actual journal entry in the prior year, as we only want to offset the BBF that was created. To change the setting, follow these steps: 

In Microsoft Dynamics GP, point to Tools on the Microsoft Dynamics GP menu, point to Setup, point to Financial and then click General Ledger

In the Maintain History area, click to clear the Accounts checkbox and the Transactions check box.
In the Allow area, click to select the Posting to History check box. We want to be able to post an offsetting journal entry using a prior year date. Click OK.
Reopen the period for the prior Fiscal Year. To do this, follow these steps. 
In Microsoft Dynamics GP, point to Tools on the Microsoft Dynamics GP menu, point to Setup, point to Company and then click Fiscal Periods.
In the Fiscal Periods Setup window, make sure that the Financial period for the recently closed year is open.
Enter a journal entry to offset the incorrect beginning balance. To do this, follow these steps:
On the Transactions menu, point to Financial, and then click General.
In the Transaction Entry window, enter a transaction that reverses the incorrect beginning balance of the profit-and-loss account.
In the Transaction Date field, enter a date that is in the closed fiscal year such as 12/31/201x.

For example, if the profit-and-loss account has an incorrect debit beginning balance of $100.00, create a transaction that credits the profit-and-loss account for $100.00, and then debit the retained earnings account for $100.00.

Click Post. (The General Posting Journal should show the entry listed twice.  The first is for the original entry, but due to our settings, we won't be keeping that, and the second set is for the BBF entry that will offset the balance.)

Note The transaction updates only the current year because the Maintain History settings are not enabled.

Change the Maintain History settings in the General Ledger Setup window back to how they originally were. To do this, follow these steps: 
In Microsoft Dynamics GP, point to Tools on the Microsoft Dynamics GP menu, point to Setup, point to Financial and then click General Ledger.
In the Maintain History area, click to select the Accounts checkbox and the Transactions check box.
To post the transactions to the transaction history, click to select the Posting to History check box under Allow. If you do not want to post the transactions to the transaction history, click to clear this check box. Then, click OK.

Use one of the following methods to change the Multicurrency setting back to how it originally was, depending on whether you are using multicurrency or not:
If you are registered for Multicurrency Management, follow these steps:

In Microsoft Dynamics GP, on the Microsoft Dynamics GP menu, point to Tools, point to Setup, point to Financial, and then click Multicurrency.

In the Maintain History area, click to select the General Ledger Account checkbox.
If you are not registered for Multicurrency Management, open SQL Server Management Studio and run the following statement against the company database:
UPDATE MC40000 SET MNSUMHST = 1

Go back to the Fiscal Period setup and mark to close the Fiscal Period for the prior year again.
Now you can verify the balance on the GL account is $0.00 and then you can change the type on the account to Profit and Loss. To do this, on the Cards menu, point to Financial, and then click Account. In the Account Maintenance window, type the account number in the Account field. In the Posting Type area, click Profit and Loss, and then click Save.

Method 2: The account is supposed to be a 'balance-sheet' account 

As a profit-and-loss account, this account will not have a beginning balance after the year-end closing process is completed. To change the account to a balance sheet account and to create the beginning balance, follow these steps:

On the Cards menu, point to Financial, and then click Account. In the Account Maintenance window, type the account number in the Account field. In the Posting Type area, click Balance Sheet, and then click Save. Select Balance Sheet so that the correcting entry that you make in step 6 later in this section will correctly update the beginning balance for the current year.

Use one of the following methods, depending on whether you are using multicurrency or not:
If you are registered for Multicurrency Management in Microsoft Dynamics GP, follow these steps:
In Microsoft Dynamics GP, point to Tools on the Microsoft Dynamics GP menu, point to Setup, point to Financial and then click Multicurrency.

In the Maintain History area, click to clear the General Ledger Account checkbox.
If you are not registered for Multicurrency Management, open SQL Server Management Studio and run the following statement against the company database:
UPDATE MC40000 SET MNSUMHST = 0

Change the Maintain History settings in the General Ledger Setup window using these steps: 
In Microsoft Dynamics GP, point to Tools on the Microsoft Dynamics GP menu, point to Setup, point to Financial and then click General Ledger.

In the Maintain History area, click to clear the Accounts checkbox and the Transactions check box.
In the Allow area, click to select the Posting to History check box, and then click OK.
Verify fiscal period is open so you can post to the prior year. To do this, follow these steps. 
In Microsoft Dynamics GP, point to Tools on the Microsoft Dynamics GP menu, point to Setup, point to Company and then click Fiscal Periods.

In the Fiscal Periods Setup window, make sure that the Financial period for the recently closed year is open.

Enter a journal entry to create a beginning balance for the account. To do this, follow these steps:
On the Transactions menu, point to Financial, and then click General.

In the Transaction Entry window, enter a transaction that creates the correct beginning balance of the balance sheet account.
In the Transaction Date field, enter a date that is in the closed fiscal year.

For example, if the balance sheet account should have a debit beginning balance of $100.00, create a transaction that credits the retained earnings account for $100.00 and that debits the balance sheet account for $100.00.
Click Post.

Note The transaction updates only the current year because the Maintain History settings are not enabled.

Change the Maintain History settings in the General Ledger Setup window back to how they originally were. To do this, follow these steps: 

In Microsoft Dynamics GP, point to Tools on the Microsoft Dynamics GP menu, point to Setup, point to Financial and then click General Ledger.

In the Maintain History area, click to select the Accounts checkbox and the Transactions check box.

To post the transactions to the transaction history, click to select the Posting to History check box under Allow. If you do not want to post the transactions to the transaction history, click to clear this check box. Then, click OK.

Go back to the Fiscal Period setup and mark to close the Fiscal Period for the prior year again
Use one of the following methods to change the Multicurrency setting back to how it originally was, depending on whether you are using multicurrency or you are not:

If you are registered for Multicurrency Management, follow these steps:

In Microsoft Dynamics GP, point to Tools on the Microsoft Dynamics GP menu, point to Setup, point to Financial and then click Multicurrency.
In the Maintain History area, click to select the General Ledger Account checkbox.
If you are not registered for Multicurrency Management, open SQL Server Management Studio and run the following statement against the company database:
UPDATE MC40000 SET MNSUMHST = 1

Microsoft SQL Server VS Oracle

There are many different relational database management systems (RDBMS) out there. You have probably heard about Microsoft Access, Sybase, and MySQL, but the two most popular and widely used is Oracle and MS SQL Server.  Although there are many similarities between the two platforms, there are also a number of key differences. In this blog, I will be taking a look at several in particular, in the areas of their command language, how they handle transaction control and their organization of database objects.

Language

Perhaps the most obvious difference between the two RDBMS is the language they use. Although both systems use a version of Structured Query Language or SQL, MS SQL Server uses Transact SQL, or T-SQL, which is an extension of SQL originally developed by Sybase and used by Microsoft. Oracle, meanwhile, uses PL/SQL, or Procedural Language/SQL. Both are different “flavors” or dialects of SQL and both languages have different syntax and capabilities. The main difference between the two languages is how they handle variables, stored procedures, and built-in functions. PL/SQL in Oracle can also group procedures together into packages, which can’t be done in MS SQL Server. In my humble opinion, PL/SQL is complex and potentially more powerful, while T-SQL is much more simple and easier to use.

Transaction Control

Another one of the biggest differences between Oracle and MS SQL Server is transaction control. For the purposes of this article, a transaction can be defined as a group of operations or tasks that should be treated as a single unit. For instance, a collection of SQL queries modifying records that all must be updated at the same time, where (for instance) a failure to update any single records among the set should result in none of the records being updated. By default, MS SQL Server will execute and commit each command/task individually, and it will be difficult or impossible to roll back changes if any errors are encountered along the way. To properly group statements, the “BEGIN TRANSACTION” command is used to declare the beginning of a transaction, and either a COMMIT statement is used at the end. This COMMIT statement will write the changed data to disk, and end the transaction. Within a transaction, ROLLBACK will discard any changes made within the transaction block. When properly used with error handling, the ROLLBACK allows for some degree of protection against data corruption. After a COMMIT is issued, it is not possible to roll back any further than the COMMIT command.

Within Oracle, on the other hand, each new database connection is treated as a new transaction. As queries are executed and commands are issued, changes are made only in memory and nothing is committed until an explicit COMMIT statement is given (with a few exceptions related to DDL commands, which include “implicit” commits, and are committed immediately). After the COMMIT, the next command issued essentially initiates a new transaction, and the process begins again. This provides greater flexibility and helps for error control as well, as no changes are committed to disk until the DBA explicitly issues the command to do so.

Organization of Database Objects

The last difference I want to discuss is how the RDBMS organizes database objects. MS SQL Server organizes all objects, such as tables, views, and procedures, by database names. Users are assigned to a log in which is granted accesses to the specific database and its objects. Also, in SQL Server each database has a private, unshared disk file on the server. In Oracle, all the database objects are grouped by schemas, which are a subset collection of database objects and all the database objects are shared among all schemas and users. Even though it is all shared, each user can be limited to certain schemas and tables via roles and permissions.

In short, both Oracle and SQL Server are powerful RDBMS options. Although there are a number of differences in how they work “under the hood,” they can both be used in roughly equivalent ways. Neither is objectively better than the other, but some situations may be more favorable to a particular choice. Either way, Segue can support these systems and help to make recommendations on how to improve, upgrade, or maintain your key mission-critical infrastructure to make sure that you can keep your focus on doing business.

How to Retrieve Lost Files in USB Flash Drive


  • Click "Start", than click on "Run" click.
  • Type "cmd" than press enter.
  • Go to the directory of your USB flash drive.
  • Type "ATTRIB -S -H *.* /S /D" and press enter and wait for a minute.
If the directory appear, type exit than open your flash drive in windows explorer and check.

Useful Qlikview Macros

Run external program
FUNCTION RunExe(cmd)
CreateObject("WScript.Shell").Exec(cmd)
END FUNCTION 
SUB CallExample
RunExe("c:\Program Files\Internet Explorer\iexplore.exe")
END SUB

Export object to Excel
FUNCTION ExcelExport(objID)
set obj = ActiveDocument.GetSheetObject( objID )
w = obj.GetColumnCount
if obj.GetRowCount>1001 then
h=1000
else
h=obj.GetRowCount
end if
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Add
objExcel.Worksheets(1).select()
objExcel.Visible = True
set CellMatrix = obj.GetCells2(0,0,w,h)
column = 1
for cc=0 to w-1
objExcel.Cells(1,column).Value = CellMatrix(0)(cc).Text objExcel.Cells(1,column).EntireRow.Font.Bold = True
column = column +1
next c = 1
r =2
for RowIter=1 to h-1
for ColIter=0 to w-1
objExcel.Cells(r,c).Value = CellMatrix(RowIter)(ColIter).Text
c = c +1
next r = r+1
c = 1
next
END FUNCTION 
SUB CallExample ExcelExport( "CH01" )
END SUB

Export object to JPG
FUNCTION ExportObjectToJpg( ObjID, fName)
ActiveDocument.GetSheetObject(ObjID).ExportBitmapToFile
fName
END FUNCTION 
SUB CallExample
ExportObjectToJpg "CH01", "C:\CH01Image.jpg" 
END SUB

Save and exit QlikView
SUB SaveAndQuit ActiveDocument.Save   
ActiveDocument.GetApplication.Quit
END SUB

Clone Dimension Group
SUB DuplicateGroups
SourceGroup = InputBox("Enter Source Group Name")
CopiesNo = InputBox("How many copies?")
SourceGroupProperties = ActiveDocument.GetGroup(SourceGroup).GetProperties
FOR i = 1 TO CopiesNo
SET DestinationGroup = ActiveDocument.CreateGroup(SourceGroupProperties.Name & "_" & i)
SET DestinationGroupProperties = DestinationGroup.GetProperties
IF SourceGroupProperties.IsCyclic THEN
DestinationGroupProperties.IsCyclic = true
DestinationGroup.SetProperties
DestinationGroupProperties
ELSE
SourceGroupProperties.IsCyclic = true
DestinationGroupProperties.SetProperties
SourceGroupProperties
END IF
SET Fields = SourceGroupProperties.FieldDefs
FOR c = 0 TO Fields.Count-1
SET fld = Fields(c)
DestinationGroup.AddField
fld.name
NEXT
Application.waitforidle
NEXT
END SUB

Open document with selection of current month
SUB DocumentOpen
ActiveDocument.Sheets("Intro").Activate
ActiveDocument.ClearAll (true)
ActiveDocument.Fields("YearMonth").Select
ActiveDocument.Evaluate("Date(MonthStart(Today(), 0),'MMM-YYYY')")
END SUB

Read and Write variables
FUNCTION getVariable(varName)
set v = ActiveDocument.Variables(varName)
getVariable = v.GetContent.String
END FUNCTION 
SUB setVariable(varName, varValue)
set v = ActiveDocument.Variables(varName)
v.SetContent varValue, true
END SUB

Open QlikView application, reload, press a button and close (put the code in a .vbs file)
Set MyApp = CreateObject("QlikTech.QlikView")
Set MyDoc = MyApp.OpenDoc ("C:\QlikViewApps\Demo.qvw","","")
Set ActiveDocument = MyDoc
ActiveDocument.Reload
Set Button1 = ActiveDocument.GetSheetObject("BU01")
Button1.Press MyDoc.GetApplication.Quit
Set MyDoc = Nothing
Set MyApp = Nothing

Delete file
FUNCTION DeleteFile(rFile)
set oFile = createObject("Scripting.FileSystemObject") 
currentStatus = oFile.FileExists(rFile) 
if currentStatus = true than
oFile.DeleteFile(rFile)
end if
set oFile = Nothing
END FUNCTION 
SUB CallExample
        DeleteFile ("C:\MyFile.PDF")
END SUB

Get reports information
function countReports
set ri = ActiveDocument.GetDocReportInfo
countReports = ri.Count
end function 
function getReportInfo
set ri = ActiveDocument.GetDocReportInfo
set r = ri.Item(i)
getReportInfo = r.Id & "," & r.Name & "," & r.PageCount & CHR(10)
end function

Send mail using Google Mail
SUB SendMail
Dim objEmail 
Const cdoSendUsingPort = 2      ' Send the message using SMTP
Const cdoBasicAuth = 1          ' Clear-text authentication
Const cdoTimeout = 60           ' Timeout for SMTP in seconds 
mailServer = "smtp.gmail.com"
SMTPport = 465
mailusername = "MyAccount@gmail.com"
mailpassword = "MyPassword" 
mailto = "destination@company.com"
mailSubject = "Subject line"
mailBody = "This is the email body" 
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields 
With objFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mailServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPport
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = cdoTimeout
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasicAuth
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = mailusername
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mailpassword
.Update
End With 
objEmail.To = mailto
objEmail.From = mailusername
objEmail.Subject = mailSubject
objEmail.TextBody = mailBody
objEmail.AddAttachment "C:\report.pdf"
objEmail.Send 
Set objFlds = Nothing
Set objConf = Nothing
Set objEmail = Nothing
END SUB

Changing Font setting of an Object
SUB Font()
set obj = ActiveDocument.GetSheetObject("BU01")
set fnt = obj.GetFrameDef.Font
fnt.PointSize1000 = fnt.PointSize1000 + 1000
fnt.FontName = "Calibri"
fnt.Bold = true
fnt.Italic = true
fnt.Underline = true
obj.SetFont fnt
END SUB

To Show and Hide Tab row
Sub ShowTab 
rem Hides tabrow in document properties 
set docprop = ActiveDocument.GetProperties 
docprop.ShowTabRow=true 
ActiveDocument.SetProperties docprop 
End Sub 
 
Sub HideTab 
rem Hides tabrow in document properties 
set docprop = ActiveDocument.GetProperties 
docprop.ShowTabRow=false 
ActiveDocument.SetProperties docprop 
End Sub 

Always One Selected Enable / Disable setting through Macro
Sub AlwaysOneSelected 
set obj = ActiveDocument.GetSheetObject("LB02") 
  set boxfield=obj.GetField 
  set fprop = boxfield.GetProperties 
  fprop.OneAndOnlyOne = True 
  boxfield.SetProperties fprop 
End Sub 
 
Sub RemoveAlwaysOneSelected 
set obj = ActiveDocument.GetSheetObject("LB02") 
    set boxfield=obj.GetField 
    set fprop = boxfield.GetProperties 
  fprop.OneAndOnlyOne = False 
  boxfield.SetProperties fprop 
  ActiveDocument.ClearAll True 
End Sub 

Reading Rows and Columns in a table object
Sub ReadStraightTable
Set Table = ActiveDocument.GetSheetObject( "CH01" )
For RowIter = 0 to table.GetRowCount-1
  For ColIter = 0 to table.GetColumnCount-1
set cell = table.GetCell(RowIter,ColIter)
        Msgbox(cell.Text)
Next
Next
End Sub

Get number of Rows in a Straight or Pivot tables
function ReadRowsCount
set v = ActiveDocument.GetVariable("variableName")
v.SetContent  ActiveDocument.GetSheetObject( "CH01" ).GetRowCount-1, true
end function

Get and Set variable values in macros
function setVariable(name, value)
set v = ActiveDocument.GetVariable("variableName")
  v.SetContent value,true
end function

function getVariable(name)
set v = ActiveDocument.GetVariable("variableName")
getVariable = v.GetContent.String
end function

Export chart data to QVD file, the chart may Bar/Line/StraightTable/Pivot etc.
sub ChartToQVD 
set obj = ActiveDocument.GetSheetObject("CH01") 
obj.ExportEx "QvdName.qvd", 4 
end sub 

Export Charts as image for each value selection in a Listbox
FUNCTION ExportObjectToJpg( ObjID, fName) 
ctiveDocument.GetSheetObject(ObjID).ExportBitmapToFile fName 
END FUNCTION 
 
SUB ExportChartByListboxValues 
DIM fname, value, filePath, timestamp 
  filePath = ActiveDocument.Variables("vPDFFlagPath").GetContent.STRING 
  timestamp = Year(Now()) & DatePart("m", Now()) & DatePart("d", Now()) & DatePart("h", Now()) & DatePart("n", Now()) &     DatePart("s", Now()) 
  SET Doc = ActiveDocument 
  fieldName = "EmployeeID" 
  SET Field = Doc.Fields(fieldName).GetPossibleValues 

  FOR index = 0 to Field.Count-1 
Doc.Fields(fieldName).Clear 
  Doc.Fields(fieldName).SELECT
Field.Item(index).Text 
  fileName = Field.Item(index).Text & "_" & timestamp   & ".jpg"'Field.Item(index).Text & DateValue 
  ExportObjectToJpg "CH420", filePath & fileName 
NEXT 
  Doc.Fields(fieldName).Clear 
END SUB 

Checks whether given folder exists if not creates the given folder
Function CheckFolderExists(path) 
Set fileSystemObject = CreateObject("Scripting.FileSystemObject") 
  If Not fileSystemObject.FolderExists(path) Than 
        fileSystemObject.CreateFolder(path) 
  End If 
End Function 

Minimize the chart object and move the chart position 20 pixels down and 15 right
Sub MoveChart 
set mybox = ActiveDocument.GetSheetObject("CH09") 
  mybox.Minimize 
  set fr = mybox.GetFrameDef 
  pos = fr.MinimizedRect 
  pos.Top = pos.Top + 20 
  pos.Left = pos.Left + 15 
  mybox.SetFrameDef fr 
end sub 

Move Chart Object 20 pixels down and 15 right
Sub MoveChart
  set obj = ActiveDocument.GetSheetObject("CH09")
    pos = obj.GetRect
    pos.Top = pos.Top + 20
    pos.Left = pos.Left + 15
    obj.SetRect pos
End Sub

Export Table charts Side by Side in a single Excel sheet
Function ExportCharts() 
  Set xlApp = CreateObject("Excel.Application") 
  xlApp.Visible = true 
  Set xlDoc = xlApp.Workbooks.Add 'open new workbook 
  nSheetsCount = 0 
  CALL RemoveDefaultSheet(xlDoc) 
 
  nSheetsCount = xlDoc.Sheets.Count 
  xlDoc.Sheets(nSheetsCount).Select 
  Set xlSheet = xlDoc.Sheets(nSheetsCount) 
 
  CALL ExportRevenueWidgets(xlDoc,xlSheet) 
End Function 
 
'Call Export Widgets By Sheet 
Function ExportRevenueWidgets(xlDoc,xlSheet) 
  CALL Export(xlDoc,xlSheet,"CH09", "A") 
  CALL Export(xlDoc,xlSheet,"CH09", "D") 
End Function 
 
'Export Widgets 
Function Export(xlDoc, xlSheet,widgetID, columnStart) 
    nRow = xlSheet.UsedRange.Rows.Count 
    nRow = 1 
  Set SheetObj = ActiveDocument.GetSheetObject(widgetID) 
 
  'Copy the chart object to clipboard 
  SheetObj.CopyTableToClipboard true 
 
  'Paste the chart object in Excel file 
  xlSheet.Paste xlSheet.Range(columnStart&nRow) 
End Function 
 
'Remove Default Sheets from Excel Files 
Sub RemoveDefaultSheet(xlDoc) 
  Do 
  nSheetsCount = xlDoc.Sheets.Count 
  If nSheetsCount = 1 than 
  Exit Do 
  Else 
  xlDoc.Sheets(nSheetsCount).Select 
  xlDoc.ActiveSheet.Delete 
  End If 
Loop 
End Sub 

Setting Scroll bar of a chart to Right side by default
SUB StartScrollRight 
         SET chartObject = ActiveDocument.GetSheetObject("CH01") 
         SET chartProperties = chartObject.GetProperties 
         chartProperties.ChartProperties.XScrollInitRight = true 
         chartObject.SetProperties chartProperties 
END SUB 

Show hide expression in Straight / Pivot table
Sub ShowHideExpression() 
SET chartObj = ActiveDocument.GetSheetObject("CH01") 
SET chartProp= chartObj.GetProperties 
SET expr = chartProp.Expressions.Item(1).Item(0).Data.ExpressionData 
  expr.Enable = False // Hides First expression 

SET expr = chartProp.Expressions.Item(2).Item(0).Data.ExpressionData 
expr.Enable = True // Displays Second expression 
End Sub

To reset InputField values
Sub ResetInputField
' Reset the InputField
  set fld = ActiveDocument.Fields("InputFieldName")
  fld.ResetInputFieldValues 0,  0   ' 0 = All
values reset, 1 = Reset Possible value, 2 = Reset single value
End Sub

To set InputField values
Sub SetInputField
set fld = ActiveDocument.Fields("Budget")
      fld.SetInputFieldValue 0, "999"  ' Sets InputField value to 999
End Sub

Clear specific Fields
SUB ClearFields
      SET Doc = ActiveDocument
      Doc.Fields(FieldName1).Clear
      Doc.Fields(FieldName2).Clear
      Doc.Fields(FieldName3).Clear
      Doc.Fields(DateFieldNameN).Clear
END SUB

Export chart to CSV
SUB ExportChartToCSV
      SET  objChart = ActiveDocument.GetSheetObject("CH01")
      objChart.Export "C:\Data.CSV", ", "
END SUB

Fit zoom to Window
Sub FitZoomToWindow 
ActiveDocument.GetApplication.WaitForIdle 
ActiveDocument.ActiveSheet.FItZoomToWindow 
End Sub 

Macro to get fast change chart type in a variable
10 - Pivot Table
11 - Straight Table
12 - Bar
15 - Line

Sub GetChartType() 
set chart = ActiveDocument.getsheetobject("CH01") 
  set p = chart.GetProperties 
 
  set v = ActiveDocument.GetVariable("vFastChangeChartType") 
    v.SetContent
chart.GetObjectType,true 
end sub 

Open IE browser with URL based on a selected Dimension value - Use below macro in Document Properties Field Event Triggers
Create a variable
vSelectedURL : =Only([Image Location])

Sub Browse()
set v = ActiveDocument.GetVariable("vSelectedURL")
    Set ie = CreateObject("Internetexplorer.Application")
    ie.Visible = True
    ie.Navigate v.GetContent.String
End Sub

Export multiple chart to Microsoft PowerPoint slides
Sub ExportPPT 
Set objPPT = CreateObject("PowerPoint.Application") 
objPPT.Visible = True 
Set objPresentation = objPPT.Presentations.open("YourPath\ppt.pptx")'file Path 
Set PPSlide =objPresentation.Slides.Add(1,12) 
ActiveDocument.GetSheetObject("CH1").CopyBitmapToClipboard 
PPSlide.Shapes.Paste 
PPSlide.Shapes(PPSlide.Shapes.Count).Top = 150 'This sets the top location of the image 
PPSlide.Shapes(PPSlide.Shapes.Count).Left = 15 'This sets the left location 
PPSlide.Shapes(PPSlide.Shapes.Count).Width = 240 
PPSlide.Shapes(PPSlide.Shapes.Count).Height = 250 
 
Set PPSlide = objPresentation.Slides.Add(1,12) 
ActiveDocument.GetSheetObject("CH2").CopyBitmapToClipboard 
PPSlide.Shapes.Paste 
PPSlide.Shapes(PPSlide.Shapes.Count).Top = 150 'This sets the top location of the image 
PPSlide.Shapes(PPSlide.Shapes.Count).Left = 15 'This sets the left location 
PPSlide.Shapes(PPSlide.Shapes.Count).Width = 100 
PPSlide.Shapes(PPSlide.Shapes.Count).Height = 200 
 
Set PPSlide = Nothing 
Set PPPres = Nothing 
Set PPApp = Nothing 
End Sub 

Copy to Clip Board -Bit Map Image
Sub CopyObject 
ActiveDocument.GetSheetObject("CH01").CopyBitmapToClipboard 
End sub 

Append data to existing Excel file
Sub AppendDataToExcel 
dim doc, xlApp, xlDoc, xlSheet, LastRow 
Const xlUp = -4162 
set doc = ActiveDocument 
Set xlApp = CreateObject("Excel.Application") 
Set xlDoc = xlApp.Workbooks.Open("C:\Data.xlsx") ' Change filepath 
xlapp.Visible = true  ' you can also set it to false so that process done in background 
Set xlSheet = xlDoc.Worksheets("Sheet1")   ' Replace Sheet1 with your sheet name 
xlSheet.Activate 
LastRow = xlSheet.Cells(xlSheet.Rows.Count, 1).End(xlUp).Row 
msgbox LastRow 
xlSheet.Cells(LastRow + 1, 1).Select 
doc.GetSheetObject("TB01").CopyTableToClipboard true   'Replace TB01 with your chart object ID 
xlSheet.Paste 
xlDoc.Save 
xlDoc.Close 
xlApp.Quit 
End Sub 

Export all objects of a Container to Excel
sub Export 
  set oXL = CreateObject("Excel.Application") 
  oXL.DisplayAlerts = False 
  oXL.visible=True 
  Dim oXLDoc 'as Excel.Workbook 
  Dim i 
 
  Set oXLDoc = oXL.Workbooks.Add 
 
  '--------------------------------------- 
  Set ContainerObj = ActiveDocument.GetSheetObject("CT02") 
    Set ContProp=ContainerObj.GetProperties 
  aSheetObj=Array("CH02","CH03","CH06") 
  '--------------------------------------- 
 
  for i=0 to UBound(aSheetObj) 
 
  'ActiveDocument.GetApplication.WaitForIdle 
    oXL.Sheets.Add 
  oXL.ActiveSheet.Move ,oXL.Sheets( oXL.Sheets.Count ) 
 
 
        ContProp.SingleObjectActiveIndex = i 
        ContainerObj.SetProperties ContProp 
 
  Set oSH = oXL.ActiveSheet 
      oSH.Range("A1").Select 
   
      Set obj = ActiveDocument.GetSheetObject(aSheetObj(i)) 
      obj.CopyTableToClipboard True 
      oSH.Paste 
      sCaption=obj.GetCaption.Name.v 
      set obj=Nothing 
 
  oSH.Rows("1:1").Select 
  oXL.Selection.Font.Bold = True 
 
      oSH.Cells.Select 
      oXL.Selection.Columns.AutoFit 
   
      oSH.Range("A1").Select   
  oSH.Name=left(sCaption,30) 
 
  set oSH=Nothing 
 
  next 
 
Call Excel_DeleteBlankSheets(oXLDoc) 
 
  oXL.DisplayAlerts = True 
  '// Finally select the first sheet 
    oXLDoc.Sheets(1).Select 
 
  '--------------------------------------- 
set oXL    =Nothing 
  set oXLDoc =Nothing 
end sub 
 
Private Sub Excel_DeleteBlankSheets(ByRef oXLDoc) 
  For Each ws In oXLDoc.Worksheets 
  If (not HasOtherObjects(ws)) than 
  If oXLDoc.Application.WorksheetFunction.CountA(ws.Cells) = 0 Than 
  On Error Resume Next 
      Call ws.Delete() 
  End If 
  End If 
  Next 
End Sub 
 
Public Function HasOtherObjects(ByRef objSheet) 'As Boolean 
    Dim c 
    If (objSheet.ChartObjects.Count > 0) Than 
    HasOtherObjects = true 
    Exit function 
    End If 
    If (objSheet.Pictures.Count > 0) Than 
    HasOtherObjects = true 
    Exit function 
    End If 
    If (objSheet.Shapes.Count > 0) Than 
    HasOtherObjects = true 
    Exit function 
    End If 
   
    HasOtherObjects = false 
End Function 

Get list of bookmarks in Variable
Sub GetBookmarks 
bookmarks = ActiveDocument.GetDocBookmarkNames 
dim BM 
for i = lbound(bookmarks) to ubound(bookmarks) 
          if(i=0) then 
                    BM="'"&bookmarks(i)&"'" 
          else 
              BM=BM&",'"&bookmarks(i)&"'" 
        end if 
next 
set v = ActiveDocument.GetVariable("vVariable") 
v.SetContent BM,true 
End Sub 

Export charts for each bookmark in separate excel sheets
Function ExportCharts()   
Set xlApp = CreateObject("Excel.Application")   
  xlApp.Visible = true   
  Set xlDoc = xlApp.Workbooks.Add 'open new workbook   
  nSheetsCount = 0   
  CALL RemoveDefaultSheet(xlDoc)   
   
bookmarks = ActiveDocument.GetDocBookmarkNames 
   
for i = lbound(bookmarks) to ubound(bookmarks) 
ActiveDocument.RecallDocBookmark  bookmarks(i) 
nSheetsCount = xlDoc.Sheets.Count   
msgbox nSheetsCount 
  xlDoc.Sheets(nSheetsCount).Select   
  Set xlSheet = xlDoc.Sheets(nSheetsCount) 
  msgbox xlSheet.Name 
  CALL ExportRevenueWidgets(xlDoc,xlSheet) 
   
  ' set nSheetsCount = nSheetsCount + 1 
  if i <> ubound(bookmarks) than 
  xlDoc.Sheets.Add   
  xlDoc.ActiveSheet.Move ,xlDoc.Sheets( xlDoc.Sheets.Count ) 
  end if 
   
  ' msgbox xlDoc.Sheets.Count         
next   
End Function   
   
'Call Export Widgets By Sheet   
Function ExportRevenueWidgets(xlDoc,xlSheet)   
  CALL Export(xlDoc,xlSheet,"CH01", "A")   
  CALL Export(xlDoc,xlSheet,"CH02", "D")   
End Function   
   
'Export Widgets   
Function Export(xlDoc, xlSheet,widgetID, columnStart)   
    nRow = xlSheet.UsedRange.Rows.Count   
    nRow = 1   
  Set SheetObj = ActiveDocument.GetSheetObject(widgetID)   
   
  'Copy the chart object to clipboard   
  SheetObj.CopyTableToClipboard true   
   
  'Paste the chart object in Excel file   
  xlSheet.Paste xlSheet.Range(columnStart&nRow)   
End Function   
   
'Remove Default Sheets from Excel Files   
Sub RemoveDefaultSheet(xlDoc)   
  Do   
  nSheetsCount = xlDoc.Sheets.Count   
  If nSheetsCount = 1 than   
  Exit Do   
  Else   
  xlDoc.Sheets(nSheetsCount).Select   
  xlDoc.ActiveSheet.Delete   
  End If   
  Loop   
End Sub