SOLVED

Importing Data into Outlook Calendar

Steel Contributor

Hello,

I am trying to upload excel data into an Outlook calendar.

I have an error on my code on WScript   "Variable Not Defined"

strFil = WScript.Arguments(0)

(row ~25)

I am not sure why.  

I have attached the code in Notepad.

Do  you see where the issue might be?  

Note:  I am not a coder. 

 

thank you very much

15 Replies

@Tony2021 

Two questions.

One. This forum is devoted to the MS Access application, used to create relational database applications. So, are you trying to import data in Outlook from Excel from code running in an Access module? Or in Outlook? Or in Excel? (Well, three questions about one topic.)

Two, you show only one line, the one with the error. The error message is telling you that you are trying to use an undefined variable, and you've bolded the word "WScript" so we are to assume, I guess, that this is the undefined variable.

 

Maybe if you show us the entire procedure (Sub or Function) we can help clarify why that variable isn't defined.

 

Hello there George, thank you for your response. Sorry for my tardy reply. I have been swampted with my real job. I would really love to get this code working. Any assistance is greatly appreciated.
To answer your queries:
<So, are you trying to import data in Outlook from Excel from code running in an Access module? Or in Outlook? Or in Excel? (Well, three questions about one topic.)
Answer: Yes. My data resides in Access, then I dump it to excel then upload into Outlook.
<Maybe if you show us the entire procedure (Sub or Function) we can help clarify why that variable isn't defined.
Yes, I think its in the zipped attachment? The function is called "OutlookCalendarScript" which is inside the text file.

Let me know if there is something I have missed.

@George Hepworth 

----Or---- it could be easier to provide guidance on how I could import the attached excel into Outlook.

 

 

Why move the data through Excel at all? I'm not sure I understand that part.
IF that is real data in the Excel file I suggest you delete it. It contains email addresses.

@Tony2021 

I see the text.

So this is running from Access. Apparently you first export the data from Access to Excel (in a different function?) Why do that? Is there some additional formatting being done in Excel? How does this data get stored in Access?

Also, many of your variables are Dimmed this way.

Dim excApp, excWkb, excWks, excCel

This results in variant type variables. I suspect what you want are Excel Objects here, but if you do want the variant datatype, it's okay.

 

I see you use WScript without previously dimming or setting it. I can't see how that can work. Where does that come from?

 

@George Hepworth 

Hi George,

 

I do extra formatting and combining fields and preparing it for importing into Outlook.  My data is initially in excel then I import into Access, manipulate it then re-export to excel then into Outlook.  I use to be able to skip the re-export to excel by using the script.  

 

I am not sure where that Wscript came from. It is only in the code I posted.  I searched my access database and I do not see it anywhere else but in that function OutlookCalendarScript().  I thought maybe there is a reference or something that  I need to update but I dont see any missing references either.  

 

I think I will have to end up importing into Outlook manually.  I have actually managed to do this and it works better than expected.  its one more step but I can deal with it.  

 

thank you for your assistance.  Have a good weekend. 

Okay. Check your references and see if one refers to "Scripting"

@Tony2021 

Actually, I wonder if this is new code to you? Did it ever work?

 WScript.Arguments(0) strikes me as being something from a Windows Script, not in VBA. I made the mistake of thinking it was a variable you'd set yourself.

 

@George Hepworth 

Hi George, hope you are enjoying the weekend.  

Yes, it is a variable to set according to the Compile Error:

 

Tony2021_0-1631379826280.png

 

It's also possible that Access "thinks" it is supposed to be a variable.

I should have asked about this earlier, too. Is this code you wrote yourself?
Hi George,

To answer your question, no, I did not write any of the code.
Way above my head to be honest. I am far from a coder.
I did have Microsoft Script in the references already but it didnt change anything
best response confirmed by Tony2021 (Steel Contributor)
Solution
Given the fact that this is not your own code, and that particular reference appears to be unexplainable given what we can see, I might want to go to the source of the code and ask for clarification. I suspect that you are missing some important part of the full code. As I think I mentioned in a previous post, I would expect the WScript reference to pertain to a Windows scripting function anyway.

thanks George. Its code I am pulling from an old database. I will need to explore further. thank you again for your insight.
1 best response

Accepted Solutions
best response confirmed by Tony2021 (Steel Contributor)
Solution
Given the fact that this is not your own code, and that particular reference appears to be unexplainable given what we can see, I might want to go to the source of the code and ask for clarification. I suspect that you are missing some important part of the full code. As I think I mentioned in a previous post, I would expect the WScript reference to pertain to a Windows scripting function anyway.

View solution in original post