VBA: Mail Merge - Field not found dialogue box - excel

I've been writing a tool to extract data out of an SQL database via a set of ODBC tables inside Excel VBA and insert the information into some pre-formatted reports using a mail merge and a Word Object. Some of the reports have some optional fields that may not always contain data. In these occasions those optional fields will be absent in the database entirely.
My code has been designed to be dynamic and produce the merge information (by way of a CSV file merged using VBA) using the question details in the database as the field headers. My problem stems from when the option questions are absent from the output merge file and Word prompts the user to "Remove Field". I've struggled to find a programmatic way to essentially answer this dialogue box on behalf of the user (which will always be to remove the field), or have word just know what to do and not require to ask.
I've had no luck finding a module, command or function that will either tell the word object to clean this up automatically, or any handler to answer the question programmatically. Any help would be appreciated.

Just incase someone else falls into a similar problem, here is how i solved this issue:
Instead of opening up a datasource, open up a headersource instead. In my case the headsource and data source are the same file.
Compare the merge fields (< word doc object >.MailMerge.Fields) to the fields inside your file (< word doc object >.MailMerge.DataSource.FieldNames). Delete each merge field when it is not found (< MailMergeField >.delete).
Open the data source as normal and set the first record to 2 if its the same file as your headerfile.

Related

Update Sharepoint-List with with excel-file using power automate

I'm using PowerApps to modify a list (list A) in Sharepoint. Some of the data displayed in this list is from another list (list B), displayed using lookup. Every week I update list B, with data I get from a automated email. The email contain a excel spreadsheet.
I would like to automate this, but I've run into so many issues I'm not even sure it is possible anymore.
This is my flow:
To my knowledge, it isn't possible to update a list directly from a excel file, unless the excel file is formatted as a table. Instead I have a empty file on my sharepoint that I update, which I later try to use as the source for updating list B.
Sadly this file is either locked by myself, or it won't recognize my table.
Any solutions to solve this problem would be helpful!
Just insert a create table step into the flow.
So you will:
Receive an email with the new Excel file.
Save that temporarily in a secured spot.
Create table on the data required.
Use the table to update the SharePoint list.
I've done that, then I've taken the data listed and added it to a SharePoint list using sample data from a website about single board computers, here:

Create Excel metadata using VBA to filter in sharepoint

I am trying to use metadata from an Excel file to use for filtering in our sharepoint libraby.
The excel file already contains dropdown menus to pick certain values from, which are then used to create a very lengthy filename. However for our new sharepoint libraby I would like to move those to metadata, so it can be made visible in sharepoint columns and users can filter.
The file is a template that should be filled by users and when ready saved after choosing certain values.
The creation of the filename is done in VBA and therefore all values I want to use are available there.
I've tried a number of approaches I found in forums using e.g. customdocumentproperties and made it work...sometimes... While it worked in the beginning, I cannot make it work now.
It seems changing the metadata is a problem. Creating the metadata fields for the first time worked, but then changing it, did not. I have the feeling I do not understand some basics on this action. Microsoft websites are not of any help here...
What is the best - flawless - way to use VBA to create, add, change metadata in the excel-file that can be made visiblle in the sharepoint library? And are there any typical problems?

Pulling all info from open Access subform into excel

We are using a access front end that is being developed externally. It displays a form that contains numerous points of data and a few subforms.
I am trying to code a excel sheet that would pull data from various places in the currently open form.
I have gotten as far as to be able to access all the points of data in the main form and the first line in the subforms using the following code (In this example, the "pnum", is the left most field displayed in the subform):
Set objacc = GetObject("xxxxx\Database.accdb").Application
Debug.Print objacc.Forms("mainform").Controls("main subform").Controls("Pnumber")
This works and gets me the value of the very first element named "Pnumber" in the main subform.
However, the way the subform is formulated, it can have anywhere between 1 and 30+ "Pnumber" fields.
I need a way to pull everything that the currently visible (filtered down) subform contains regardless of how many lines there are.
Thanks!
If I were the developer of that Access application, and you asked me for this feature, I would code an API for you to automate getting the right data.
One approach I can think of in this particular case would be to populate some temporary tables, on request from Excel VBA, and have Excel use the Access database file as an external source of data. Or Access could be coded to push the right data into the open Excel worksheet.
The way you would get access to the data in its current state in the form (filtered, sorted, etc.) would probably be best through the RecordsetClone property of that (sub)form. At least that's what I imagine I would use to implement that feature.

How to load prompt values from Excel or CSV files in WebI?

We have report and users want to upload filters to prompts on the reports from excel or csv files. They cannot enter one by one because they sometimes have hundreds of values (customer numbers) to filter. Is there a way to do that? If it is then how is it possible?
Thanks in Advance.
Niki
I'm assuming you're using either Web Intelligence or a different document format that is supported by the OpenDocument feature.
One possibility is to use an Excel file with a column for each prompt value. Use this Excel file as a source for a new Web Intelligence document. Within that document, construct OpenDocument URLs that contains the prompt values you want to pass.
Make sure that you read the OpenDocument manual carefully, as the syntax for passing prompt values differs depending on how the prompt is configured (single value vs. multiple values, etc).
The idea behind this is that you have an easy to maintain Excel file to input/modify the prompt values, and that end-users can open the intermediate Web Intelligence document, refresh it (or use refresh on open) and then click one of the generated links to automatically open the correct document and have all the prompt values filled in.
Example
Consider the screenshot below. It's an Excel file that contains information regarding two documents (Dummy Report and Other Report) as well as their internal ID (CUID) and the prompt values to refresh them with.
This is sufficient information to generate an OpenDocument URL to open these documents for us and automatically enter the prompt values.
The resulting URLs would look like this:
http://<servername>:<port>/BOE/OpenDocument/opendoc/openDocument.jsp?iDocID=Aa6GrrM79cRAmaOSMGoadKI&sIDType=CUID&lsSYear=2015&lsSMonth=2
http://<servername>:<port>/BOE/OpenDocument/opendoc/openDocument.jsp?iDocID=Aa6GrrM79cRAmaOSMGoadKI&sIDType=CUID&lsSYear=2015&lsSMonth=2&lsSCity=Berlin
Some remarks here:
If your documents have different prompts (e.g. City is a prompt in the second document but not in the first), or some of the prompts are optional, you'll have to check for which columns (prompts) a value has been provided in the Excel sheet and discard the empty ones (should be easy enough).
Unless Single Sign-On (SSO) has been configured in your BusinessObjects environment, you'll still have to log on.
Due to this approach, you can make prompt values dynamic (e.g. use the current year) by using Excel formulas.
The example above is a very simple one. You could have multiple lines referring to the same document but with different prompt values.
Taking it one step further
If you use this Excel sheet as a data source for a Web Intelligence document, you can create a Webi document that contains the OpenDocument links. The added bonus is that you won't have to log on anymore after clicking one of the links, as you're already working in an authenticated session.
Important
Make sure you read the OpenDocument manual carefully so you understand what it is and how it can be used (and more importantly, what you can't do with it). You can find the manual on help.sap.com. Just make sure the version described in the manual corresponds with the version of BusinessObjects deployed in your environment.
Not currently possible. What we did for this requirement was to create a new dedicated table in our database to hold customer-generated prompt values. We then created a simple web page to allow users to upload lists of values. Finally, we created universe objects that associate the customers' LOV table with existing universe objects as filters.

sharepoint list version history export to excel

Good day !
I need to do the export versions of the log data item in the excel.
This solution I unfortunately cannot use because I'm from Russia, and the solution only supports the Latin alphabet.
so I have the most to learn to extract data from the version history for a single item list.
please help. how is this done?
While I haven't found a clean way of doing this, I have a partial workaround.
Use the Export to Excel option in the List section of the ribbon (make sure the list view you export includes a modified column - thanks T6J2E5).
Save the owssvr.iqy file and open with notepad
Copy just the URL from the file and paste it back into your browser, adding "&IncludeVersions=TRUE"
Save the XML file and open in Excel (or your favorite XML viewer), selecting the "As an XML table" open option.
You'll have to delete the first few columns and rows as they contain the schema data but other than that you should have all the version history (I suggest you add the Version column to the view). You can sort by the Modified column to get a chronological change log of the entire list.
FYI "IncludeVersions=TRUE" should be before the List ID for anyone else that needs this.
spurl/_vti_bin/owssvr.dll?XMLDATA=1&IncludeVersions=TRUE&List={ListID}&View={VIEWID}&RowLimit=0&RootFolder=name
I am facing Error after doing the same that semicolon is missing. how to resolve it.

Resources