Due to server rights I can not access the word object and can only starts word on the client by hyperlinking in asp, such as:
file:///Z:/Prosjekt/32637/LS_32637_PR_01_A.docm
However I would like to run a spefic macros with parameters, can I somehow do this?
file:///Z:/Prosjekt/32637/LS_32637_PR_01_A.docm?NewFile.NewFile,1,"Test"
Maybe it is possible to write an on open event that parses the NewFile,1,"Test" to call NewFile.newFile(1,"test")
But I am not sure how to do so. Any hint on how to solve it would be great.
Related
I need to add a bunch of DOCVARIABLES to a word document for my work. The end goal is to use C# to easily ask a user what values need to go into those variables, then automatically generate the word document from the template with empty variables.
Despite having gone through and added all the field codes for the variables, when I save the document it doesn't actually initialize any of the document variables to a state where they exist, and so when I use C#, it can't find any of them. When I check the docx as a zip file, there are no <w:docVars> tags in the settings.xml file. When I add the DOCVARIABLES using the C# instead of directly through word, those tags are added.
All of the solutions I've found so far involve using a VBA Macro to initialize them to something, but that isn't an option here because, for whatever reason, we aren't allowed to use VBA Macros at all because corporate something something. There is some restriction on the computers that corporate requires them to have that entirely prevents me from running those macros, and trying to bypass that is not an option.
How do I get the DOCVARIABLES to initialize to some initial value that will allow the C# to find them?
DocVariables cannot be blank. If you set one to a null value, it is removed.
As a workaround set an initial value to “Empty” and then have your code check for that value and take appropriate action. Otherwise, just simple check if the DocVariable exists and take appropriate action if it does not.
Update:
DocVariables must be created from a macro. The macro can be in the document, a document template, or a global add-in. All require permission to run and if the IT department won’t approve any of those solutions, then DocVariables are not really an automation option.
I have a VBA function that, when invoked via a button on a sheet, extracts a .csv file from a website and imports it into my workbook. The problem is the file is uploaded in different time intervals during the day, so I have to periodically check the website.
Is there a way in VBA that I can schedule when a function is invoked?
You can use the Application.OnTime() method which will allow you to schedule a Macro for a specific time amongst other settings. However you're probably best using VB Script or similar.
It's also important to note that the workbook would need to be open the entire time if you are going to use VBA, whereas a VBS file will run silently and can be triggered to run at startup.
If you're proficient enough with VBA then you shouldn't have a problem writing VBS.
I have a scenario where users download their Word document from our local server and when they save that document, instead of saving it locally, the document is sent back to the server using a macro (which is "injected" by the server every time a user downloads a document that doesn't contains the latest version of the macro).
Now that we are going to send this solution to our final tests prior deploying it, we needed to protect that macro, I know I can password protect a macro using Microsoft Office by simply right clicking in the macro project inside the document and selecting "block from viewing" and inserting a password.
However, since the macro must be handled by the server, I need to find a way to protect that macro when I generate it, currently the macro is generated using OpenXml SDK using a VbaProjectPart. I couldn't find anything on the web.
Instead of trying to sign and protect the macro programmatically using Open Xml SDK I decided to download the document, sign it and protect it using word then I used "Open Xml SDK Productivity Tools" to "reverse engineer" the DOCM created and then I copied the binary "VbaProjectPart" created by the tool.
It's not the best way to do it since I need to have a separate documentation for this process and need to do the whole process when the macro changes, however, since the code isn't expected to change anymore I decided to go that way.
Hope this helps anyone who wants to know how to include password protected macros inside an Open Xml document.
So, let's say that I have a VBA application inside of whatever Office Application. I have created a command-line VB.net program to do all of the fun web-services stuff.
Okay, the VBA application calls Shell() to run the command line program. Now, what is the best way to get information (a tracking number for a package) from the VB.net program back into the VBA program?
My thoughts on the issue so far include:
Writing the number with Console.Write and then somehow extracting it in VBA
Or, using some kind of external interface (like a database or file system) to number the data and then get it out in VBA.
Any thoughts on this?
Why not call the Web service directly from VBA?
Check the samples in MSDN on how this can be done:
Calling XML Web Services from Office VBA Using the Web Service References Tool
Other options that you have would be:
Make your VB assembly COM-visible so that you talk to the VB code directly without having to launch a separate process
Write all relevant data to an intermediate file and read that from VBA
I would like to be able to perform SQL queries on my e-mail inbox. With the output, I can make graphs about how much e-mails I send or receive for example. I want to analyze my performance and what keeps me busy. My mailbox seems like a good place to start.
I'm using Gmail on-line, and Thunderbird, Outlook 2007 and Mail.app trough IMAP. Is there an easy way how I can connect one of those apps with something I can SQL to?
Allready tried:
Thunderbird does not have an add-on for this (or I couldn’t find it).
I suspect Outlook to be able to do something together with MS Access, but I wouldn't know how.
None of my client seems to be able to export everyting to something useful, like CVS or Excel's .xls. From there on, I can import to Access and done.
UPDATE: Access 2007 does have a wizard on connecting to outlook. But when I run it, Office starts for no reaston to complain that Outlook 2007 is not found (?).
UPDATE 2: You can fix this by setting Outlook as the default e-mail client, closing outlook and starting it again.
You can simply connect Outlook to Access via Access Wizards or code (http://support.microsoft.com/kb/209946/en-us)
You can parse mbox files (which Thunderbird uses to store it's messages) using any number of scripts like this then do any sql on the messages you like.
I agree with stalepretzel, you should probably make your own if you can't find any ready-to-go package.
What I'd do is:
Download the messages using IMAP.
Parse them and insert into your database
You could make good use of the mess822 software package to parse the mail headers, then use that to populate a database.
I think a lot of script languages (perl, python) have similar libraries (probably for IMAP as well) and should be fairly easy to hack together.
I suggest making your own addon. I'm not familiar with Thunderbird addons (and I've only dabbled in FF ones), but I assume they're like FF addons in that if you know Javascript your well on your way. I would research Thunderbird addons, and create one that runs an AJAX script whenever it receives a message. That AJAX could contact a PHP script (which you'd need to run on something like Apache, possibly just on your home computer). This PHP script, in turn, would interpret the data that Thunderbird's Javascript sent, and enter that into a database.