Jump to content

Getting a Word VB Macro to execute when sending Individual Report to document server


Recommended Posts

Posted

Hi

I have a VB Script that does some colouring in on an Individual Report, which is more complex than the colouring that SIMS can do. When I set up the Individual Report template, I put the code into the Private Sub Document_Open() bit.

 

This works when you run the report for preview or print, because word actually executes and the macro runs. However if you send the report to the document management server to store with the pupil's record, then the code never runs. If a user opens that file, the code will run then, but that's dependent on having their macro settings correct, which you can't guarantee.

 

Is there any way of getting around this? Does Word execute at all when you save an individual report or does SIMS do all the XML merging itself? If it does run, is there another Sub that I can put the code into?

 

or

 

If I go down the road of PDFing files (I see there are some threads on this), is there an easy way of Bulk Uploading to the student record? The file name by default has the student name and admissions number on it so it should be possible?

 

Thanks,

Posted
I have a VB macro in some of our individaul reports to do colour coding and as long as the member of staff accessing the linked document has their security settings to at least prompt them to enable macros the code runs. Staff all know that they should enable macros when looking at such documents.
Posted
Hi

I have a VB Script that does some colouring in on an Individual Report, which is more complex than the colouring that SIMS can do. When I set up the Individual Report template, I put the code into the Private Sub Document_Open() bit.

 

This works when you run the report for preview or print, because word actually executes and the macro runs. However if you send the report to the document management server to store with the pupil's record, then the code never runs. If a user opens that file, the code will run then, but that's dependent on having their macro settings correct, which you can't guarantee.

 

Is there any way of getting around this? Does Word execute at all when you save an individual report or does SIMS do all the XML merging itself? If it does run, is there another Sub that I can put the code into?

 

or

 

If I go down the road of PDFing files (I see there are some threads on this), is there an easy way of Bulk Uploading to the student record? The file name by default has the student name and admissions number on it so it should be possible?

 

Thanks,

 

Hi @eean - I had a macro built into the sims template to fiddle with a font, but found it didn't work on generation.

 

Did you add your own macro to the indrepbasetemplate.dot or just into the template you create through sims? I'd be interested to hear how you've done it, see an example. I can't find the document_open() sub. When i last looked to try something, all the built-in macros were password protected, so i guess you add a new one.

 

I heard on SupportNet that it's possible to get a macro to work inherently by putting it in the autorun() - i've been meaning to test this out but not had the time.

 

As far as i can tell, Word does get opened during the upload however, it's hidden from display, and for whatever reason, the document_open() isn't activated.

 

There is no easy way to bulk upload documents to the DMS. At the moment we do a load manually. There are some tools like RecordLink Writer which make it very easy, and it's not that expensive, but it's still a manual (one student at a time) process as far as i understand.

  • Thanks 1
  • 2 weeks later...
Posted

Vikpaw is largely right about bulk upload. At present RECORDLINKwriter can upload one document to multiple students but the question we are often asked is how to save multiple documents to multiple student records, eg a mail merge with variable data fields, in one action. To my knowledge there is no way of doing this. When its a matter of hard copy the solution is to scan the multiple documents as one large file and then use eCopy PaperWorks to split the document into individual files and send them to the SIMS DMS, but its not a task that I would enjoy. If its PDF, its still a manual job to upload the files from eCopy PaperWorks but at least the scanning element is missed.

 

Tim (Cohesion Software)

  • Thanks 1
Posted
Did you add your own macro to the indrepbasetemplate.dot or just into the template you create through sims?

 

I just went to Individual Report -> Word Template -> Developer -> Visual Basic

R Click This Document (I think) -> New Code

Type:


Private Sub Document_Open()

End Sub
[/Code]

 

I left the password protected macros alone - they're in the .dot file. The macros I created were in the .xml file.

 

Let me know if you want more detail and I'll go back and take a look.

 

I heard on SupportNet that it's possible to get a macro to work inherently by putting it in the autorun() - i've been meaning to test this out but not had the time.

 

I'd be interested in this. I can't find it on SupportNet - but SupportNet Search is a PITA.

 

There is no easy way to bulk upload documents to the DMS.

Thanks. Since the file name contains the student's name and Unique ID, it would hardly be a huge programmatic challenge for them to have a bulk upload option!

Posted (edited)

Ok, i'm struggling through this. I somehow made an AutoOpen macro that worked on open. This was stored in the .xml file.

What we need is to use the AutoExec routine, which then runs when Word is initiated, the problem with this is that it is an exception to the rule, so just having it in the .xml isn't good enough.

 

It will not run automatically unless it is stored in one of the following: the Normal template, a template that is loaded globally through the Templates and Add-Ins dialog box, or a global template stored in the folder specified as the Startup folder.

 

I don't think putting it in the normal template is a good idea, unless you put it in while you process the reports then take it out again. So we have to load it in a global template somehow. I looked at the Templates and Add-Ins dialog and nothing is loaded but i can choose something, so it looks like the setting will be machine / user centric. Which could be okay. I don't get how if you load a template in that dialog, it then loads the macro, how will it know it's linked to the document in question and run. Or will it just run because the rules are applied. Not sure, need to experiment some more.

 

What version of Office / Windows are you on @eean ? It probably affects things too.

Edited by vikpaw
poor grammar!
Posted

I put it into my normal.dotm and told it to load in that dialog and it says it's already loaded, and show it, which it didn't before.

Now on open, it tries to run the macro, but doesn't appear to have already run it which isn't what we want.

Also, it's trying to run it, before the document is loaded so it's erroring and saying this is no open document.

To top it off, as it's in normal.dotm it affects all docs i open, and gives me the same error.

Need some VBA ninja to assist.

Posted
What version of Office / Windows are you on @eean ? It probably has affects things too.

I've had it working on Windows XP, 7, Office 2003, 2007 and 2010!

Posted

I have got it working with AutoExec with a delay so it doesn't error on not having a document. However it only runs after the fact. If I export / upload, it hasn't run the macro yet. Whether it's held in normal or the .xml template. It runs on open only, if i suppress macros during open, the changes are not there, so whatever process does the uploading isn't triggering the macro. I'm guessing it really needs to be in that template that is locked out by password.

 

I found a Microsoft KB (286310) that states AutoExec wont run if Word is started by code, e.g.

[size=1]Set oWord = CreateObject("Word.Application")[/size]
[size=1]oWord.Visible = True[/size]


[left][size=1]oWord.Documents.Open "C:\YourFile.doc"[/size]

which i suspect is how it works.

 

I'm now wondering if the guy on SupportNet that did manage it, only had it working on open / access and all users have macro settings low enough. Or they have not realised it's an issue.[/left]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...