Change folders.

Scoth

Member
Outlook version
Email Account
Exchange Server
Hi,
I have code within a custom task form that opens a meeting request. Issue is when it's done through the task it puts the senders meeting in their task folder instead of their calendar. How to you designate the folder, currently code says currentfolder. When testing I manually changed outlook to be in calendar and it worked as it should, need to have it done through code so that these meetings will show correctly on calender, here is the current code:

Case "ENGQUALFMEA2meet"
'open fmea2 stick meeting request
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Step 1 Part Info")
Set ENGQUALFMEA2meet = myPage1.Controls("ENGQUALFMEA2meet")
'verify part number, new senior process revision, BU and Customer is filled in
Set EngQualNewSeniorRevTxt = myPage1.Controls("EngQualNewSeniorRevTxt")
Set EngQualPNTxt = myPage1.Controls("EngQualPNTxt")
Set EngQualBuUnit = myPage1.Controls("EngQualBuUnit")
Set EngQualCustNameTxt = myPage1.Controls("EngQualCustNameTxt")
Set EngQualFMEASentVal = myPage1.Controls("EngQualFMEASentVal")
If ENGQUALFMEA2MEET.Value = 0 Then EngQualFMEASentVal.Value = 0
If ENGQUALFMEA2MEET.Value = 0 Then Exit Sub
If EngQualBuUnit.Value < 1 Then
MsgBox "Business Unit Field on Step 1 Is Empty",,"Warning!!!"
ENGQUALFMEA2meet.Value = 0
Exit Sub
ElseIf EngQualPNTxt.Value = "" Then
MsgBox "Part Number Field on Step 1 Is Empty",,"Warning!!!"
ENGQUALFMEA2meet.Value = 0
Exit sub
ElseIf EngQualNewSeniorRevTxt.Value = "" Then
MsgBox "Senior New Process Revision Field on Step 1 Is Empty",,"Warning!!!"
ENGQUALFMEA2meet.Value = 0
Exit Sub
ElseIf EngQualCustNameTxt.Value = "" Then
MsgBox "Customer Name Field on Step 1 Is Empty",,"Warning!!!"
ENGQUALFMEA2meet.Value = 0
Exit Sub
End If
EngQualFMEASentVal.Value = 1
Fmea2Subject = "P/N_Sr. New Process Rev.:(" & EngQualPNTxt.Value & ")_((" & EngQualNewSeniorRevTxt.Value & "))_Business Unit{" & EngQualBuUnit.Value & "}_Customer: {{" & EngQualCustNameTxt.Value & "}}"
FMEA2Body = "Part Number: " & EngQualPNTxt.Value & Chr(13) & "Senior Process Revision: " & EngQualNewSeniorRevTxt.Value & Chr(13) & "Business Unit (If 3, Part will utilize both Business Units): " & EngQualBuUnit.Value & Chr(13) & "Customer: " & EngQualCustNameTxt.Value
Msgbox "Do Not Modify Meeting Request Subject Information",,"Caution!!!"
strform = "IPM.APPOINTMENT.FMEAStickLvl2"
Set objfolder = Application.ActiveExplorer.currentFolder
Set objItem = objFolder.Items.Add(strform)
objitem.Subject = FMEA2Subject 'added
objitem.Location = "Training Room"
'objitem.Start = Now() + 5
objitem.body = FMEA2Body

Thanks for any help you can offer.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Here is your problem:
strform = "IPM.APPOINTMENT.FMEAStickLvl2"
Set objfolder = Application.ActiveExplorer.currentFolder
Set objItem = objFolder.Items.Add(strform)

you are using current folder. You need to use calendar - try this:
Set objfolder = Application.GetDefaultFolder(olFolderCalendar)
or

Set objfolder = Session.GetDefaultFolder(olFolderCalendar)
 

Scoth

Member
Outlook version
Email Account
Exchange Server
Diane,
When trying the first suggestion it comes up with not supported, the second suggestion it come up as invalid??

Sent from my iPad using Tapatalk HD
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Both work in Outlook 2013/2010 - I'll have to check it in 2003 to verify, but I'm pretty sure it should work.
 

Scoth

Member
Outlook version
Email Account
Exchange Server
Diane,
Form was originally created in 2003, now running 2010

Sent from my iPad using Tapatalk HD
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
ok... if Set objfolder = Application.GetDefaultFolder(olFolderCalendar) doesn't work, try using
At the top put these lines:
Dim Ns As Outlook.NameSpace
Set Ns = Application.GetNamespace("MAPI")

then use this in place of the activeexplorer.currentfolder line.

Set objfolder = NS.GetDefaultFolder(olFolderCalendar)
 

Scoth

Member
Outlook version
Email Account
Exchange Server
Diane,
Thanks so much, your suggestion worked, I also tried the following and it worked as well
Set myNameSpace = Application.GetNameSpace("MAPI")
Set Application.ActiveExplorer.CurrentFolder = _
myNameSpace.GetDefaultFolder(9)

Thanks again

Sent from my iPad using Tapatalk HD
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Yes, using that to switch the current folder to the calendar works too.
 

Similar threads

Top